java中sql多条件查询
strsqlQuery="select * from 用户 where (id='"+strID+"',"+"sort='"+sort+"')";
rs=sql.executeQuery(strsqlQuery);
发生错误:
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (逗号) 在查询表达式 '( id='aa',sort='1')' 中。
请问该查询语句应该怎么写?
rs=sql.executeQuery(strsqlQuery);
发生错误:
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (逗号) 在查询表达式 '( id='aa',sort='1')' 中。
请问该查询语句应该怎么写?
...全文
请发表友善的回复…
发表回复
freedom2001 2007-08-29
- 打赏
- 举报
拜托,好好学学SQL吧,where 后面的条件是用 and (和)\or(或)等其他条件关联的,不用是逗号
godfather521 2007-08-29
- 打赏
- 举报
把这句where (id='"+strID+"',"+"sort='"+sort+"')";
改成 where id='"+strID+"' and sort = '"+sort+"' 表示 id=aa 并且sort=1 的数据
where id='"+strID+"' or sort = '"+sort+"' 表示 id=aa 或者 sort=1 的数据
多条件 用 and(与) or(或)等联接 更据你的需求选择
改成 where id='"+strID+"' and sort = '"+sort+"' 表示 id=aa 并且sort=1 的数据
where id='"+strID+"' or sort = '"+sort+"' 表示 id=aa 或者 sort=1 的数据
多条件 用 and(与) or(或)等联接 更据你的需求选择
sz_dongli 2007-08-29
- 打赏
- 举报
SQL 多条件 是 AND 不是 ,
strsqlQuery="select * from 用户 where (id='"+strID+"'and "+"sort='"+sort+"')";
strsqlQuery="select * from 用户 where (id='"+strID+"'and "+"sort='"+sort+"')";
lilome 2007-08-29
- 打赏
- 举报
and