求asp查询access数据库的sql 查询语句

2024-12-30 19:49:55
推荐回答(3个)
回答1:

给个我常用的:
我一般是将条件独立出来
whereStr = " AND sex= '男' "
whereStr = whereStr & " AND age= 20 "
whereStr = whereStr & " AND comment LIKE '%歌%' "
''如果有更多条件也是一个一个拼起来

whereStr = whereStr & " AND 条件2 "
whereStr = whereStr & " AND 条件3 "

然后SELECT 语句用
sqlStr="SELECT * FROM [table] WHERE 1=1 " & whereStr

回答2:

select * from user where sex='男' and age=20 and (name like '%歌%' or comment like '%歌%' )

回答3:

sql="select * from user where sex=‘男’ and age=20 and (name like '%歌%' or comment like '%歌%' )"