SQl添加、删除、修改语句
SQL语句的添加、删除、修改虽然有如下很多种方法,但在使用过程中还是不够用,不知是否有高手把更多灵活的使用方法贡献出来?
添加、删除、修改使用db.Execute(Sql)命令执行操作
╔----------------╗
☆ 数据记录筛选 ☆
╚----------------╝
注意:单双引号的用法可能有误(没有测式)
Sql = "Select Distinct 字段名 from 数据表"
Distinct函数,查询数据库存表内不重复的记录
Sql = "Select Count(*) from 数据表 where 字段名1>#18:0:0# and 字段名1< #19:00# "
count函数,查询数库表内有多少条记录,“字段名1”是指同一字段
例:
set rs=conn.execute("select count(id) as idnum from news")
response.write rs("idnum")
sql="select * from 数据表 where 字段名 between 值1 and 值2"
Sql="select * from 数据表 where 字段名 between #2003-8-10# and #2003-8-12#"
在日期类数值为2003-8-10 19:55:08 的字段里查找2003-8-10至2003-8-12的所有记录,而不管是几点几分。
select * from tb_name where datetime between #2003-8-10# and #2003-8-12#
字段里面的数据格式为:2003-8-10 19:55:08,通过sql查出2003-8-10至2003-8-12的所有纪录,而不管是几点几分。
Sql="select * from 数据表 where 字段名=字段值 order by 字段名 [desc]"
Sql="select * from 数据表 where 字段名 like '%字段值%' order by 字段名 [desc]"
模糊查询
Sql="select top 10 * from 数据表 where 字段名 order by 字段名 [desc]"
查找数据库中前10记录
Sql="select top n * form 数据表 order by newid()"
随机取出数据库中的若干条记录的方法
top n,n就是要取出的记录数
Sql="select * from 数据表 where 字段名 in ('值1','值2','值3')"
╔----------------╗
☆ 添加数据记录 ☆
╚----------------╝
sql="insert into 数据表 (字段1,字段2,字段3 …) valuess (值1,值2,值3 …)"
sql="insert into 数据表 valuess (值1,值2,值3 …)"
不指定具体字段名表示将按照数据表中字段的顺序,依次添加
sql="insert into 目标数据表 select * from 源数据表"
把源数据表的记录添加到目标数据表
╔----------------╗
☆ 更新数据记录 ☆
╚----------------╝
Sql="update 数据表 set 字段名=字段值 where 条件表达式"
Sql="updat
相关文档:
--创建一张表
create table stut
(
id int,
na varchar(20)
)
--插入4条数据。
insert into stut values(1,'aa')
insert into stut values(2,'bb')
insert into stut values(3,'df')
insert into stut values(4,'中国')
select * from stut
--根据'df,aa,中国,bb'来进行排序
select * from stut ......
触发器实际上就是一种特殊类型的存储过程,其特殊性表现在:它是在执行特定的T-SQL 自动相加的。
触发器分为两类:
&nbs ......
USE [rossic]
GO
/****** Object: StoredProcedure [dbo].[fn_GetLunar] Script Date: 02/23/2010 15:46:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[fn_GetLunar] ......
SELECT CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
SELECT CONVERT(varchar(100), GETDATE(), 1): 05/16/06
SELECT CONVERT(varchar(100), GETDATE(), 2): 06.05.16
SELECT CONVERT(varchar(100), GETDATE(), 3): 16/05/06
SELECT CONVERT(varchar(100), GETDATE(), 4): 16.05.06
SELECT CONVERT(varch ......
MySQL中文参考手册- 7 MySQL 语言参考
<!--
body { font-size: 9pt; }
a:hover{color:red;}
a.t1:visited{color:red;}
-->
DATABASE()
返回当前的数据库名字。
mysql> select DATABASE();
-> 'test'
如果没有当前的数据库,DATABASE()
返回空字符串。
USER()
SYSTEM_USER()
......