易截截图软件、单文件、免安装、纯绿色、仅160KB

asp网页里,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]"
模糊查询
 
注意:mysql与ORACLE数据库存在不同
Sql="select
top 10
*
from 数据表 where 字段名 order by 字段名 [desc]"
Sql="select *from数据表where字段名order   by字段名[desc]

limit
10
"
 
查找数据库中前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,


相关文档:

初学PL/SQL 游标

1,显示游标的操作
  
(1) 定义游标
      根据查询的数据情况,在PL/SQL块的声明部分定义游标,语法为:
         cursor cursor_name is select_statement;
注意:
     游标必须在PL/SQL块的声明部分进行定义; ......

自增字段的SQL语句解决方案

create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [ ......

SQL SERVER 2008 笔记之行压缩和页压缩

 
/*
    2008 压缩
 
 
    行压缩
   
    SQL SERVER 2008 引进了行压缩这个新特性,只有企业版具有该新特性.行压缩只需要最低的空间对行数据进行压缩.行压缩可以在CREATE一个表,索引或者ALTER一个表,索引的时候进行创建.压缩可以在 ......

ASP循环输出表格行tr的方法

  <%
for i=1 to rs.recordCount '变量i从1循环到数据库中的全部记录数
if (i mod 1 =1) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "<tr align='center'>"
end if
%>
此处为要循环的内容
  <%if (i mod 1 = 0) then ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号