物理仿真实验系统下载:asp中的查询语句怎么写

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 05:04:31
有表:product
字段:name,keyword
目的是要查询product内的name和keyword这两个字段内既要有“关键字A”也要有“关键字B”,也可以是两个字段内各满足一个条件。
注:要使用模糊查询,

sqlstr="select * from product where name='A' and keyword='B' "

查询字符串就这么写

这样是模糊查询:

sqlstr="select * from product where name='%A%' and keyword='%B%' "

如果不行就是这样

sqlstr="select * from product where name='"%A%"' and keyword='"%B%"' "

你的关键字是什么类型的?如果是字符串的话就像旁边那朋友写的,但是如果是int类型的就不可以了,要去掉单引号。在查询的时候使用变量还要连接字符串。

sqlstr="select * from product where name='%"& A &"%' and keyword='%"& B &"%'"