strsqlQuery="select * from 用户 where (id='"+strID+"',"+"sort='"+sort+"')";
rs=sql.executeQuery(strsqlQuery);
发生错误:
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (逗号) 在查询表达式 '( id='aa',sort='1')' 中。
请问该查询语句应该怎么写?

解决方案 »

  1.   

    SQL 多条件 是 AND 不是 ,strsqlQuery="select * from 用户 where (id='"+strID+"'and "+"sort='"+sort+"')";
      

  2.   

    把这句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(或)等联接 更据你的需求选择
      

  3.   

    拜托,好好学学SQL吧,where 后面的条件是用 and (和)\or(或)等其他条件关联的,不用是逗号