当前位置: 代码迷 >> J2ME >> java.sql.SQLException: You have an error in your SQL syntax;解决办法
  详细解决方案

java.sql.SQLException: You have an error in your SQL syntax;解决办法

热度:2776   发布时间:2013-02-25 21:34:02.0
java.sql.SQLException: You have an error in your SQL syntax;
sql = "select id,name,sex,age,idcard,nation,edu,tel,addr,health,family," +
"condition,style,time,photo,remove,operator,require,frontpay,wage from staff where remove=1 ";


执行此sql语句,会报这样的错误:java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition,style,time,photo,remove,operator,require,frontpay,wage from staff wher' at line 1



如果执行这样的sql语句:
sql = "select id,name,sex,age,idcard,nation,edu,tel,addr,health,family from staff where remove=1 ";
则不会报错。。。。什么原因呀

难道我数据库有问题,我需要在重新写一个数据库吗????


------解决方案--------------------------------------------------------
楼主是MYSQL5以上的版本吗,condition在mysql5里是保留字段,你要加单引号的
SQL code
select id,name,sex,age,idcard,nation,edu,tel,addr,health,family,'condition',style,time,photo,remove,operator,require,frontpay,wage from staff where remove=1
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Tue Nov 21 12:27:50 CST 2017
  • 最近登录:Tue Nov 21 12:27:50 CST 2017
  • 最近登录:Tue Nov 21 12:27:50 CST 2017
  • 最近登录:Tue Nov 21 12:27:50 CST 2017
  • 最近登录:Tue Nov 21 12:27:50 CST 2017