<二>常用的四种SQL命令:
1.查询数据记录(Select)
语法:Select 字段串行 From table Where 字段=内容
例子:想从book表中找出作者为"cancer"的所有记录,SQL语句便如下:
select * from book where author=’cancer’
"*"是取出book表所有的字段,如查询的字段值为数字,则其后的"内容"便无须加上单引号,如是日期,则在Access中用(#)包括,而在SQL server中则用(’)包括,
如:
select * from book where id=1
select * from book where pub_date=#2002-1-7# (Access)
select * from book where pub_date=’2002-1-7’ (SQL Server)
提示:
日期函数to_date不是标准sql文,不是所有的数据库适用,所以大家在使用的时候要参考数据库具体语法
另外如果是查询传入的变量,则如下:
strau=request.form("author")
strsql="select * from book where author=’"&strau&"’"
如果查询的是数字,则:
intID=request.form("id")
strsql="select * from book where id="&intID
在很多数据库中,如:oracle,上面的语句是可以写成:
strsql="select * from book where id='"&intID&"'"
但

