我的web应用的日志中总有类似下面的报错:
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 '-12 , 12' at line 1代码中的数据库操作语句大致为(sql在单独放在mysql中运行没有问题,其它语句的主要的语法在下面的语句中都包括了了,这是个比较全的):
SELECT a.*,(select count(*) from umyfans,uuserinfo where umyfans.myusername=a.fansusername and umyfans.fansusername=uuserinfo.username and ifnull(uuserinfo.Approval,'0')='0') as myfansnumber,(select count(*) from umyfans,uuserinfo where umyfans.fansusername=a.fansusername and umyfans.myusername=uuserinfo.username and ifnull(uuserinfo.Approval,'0')='0') as myaddfansnumber,
c.userpic as userpic,b.ConfirmTime  as confirmtime,b.name as name,b.Country as Country,
b.Province as Province,b.name as myFansName ,(select count(*) from p_design where ifnull(save,'0')='1' and ifnull(hide,'0')='0' and ifnull(abate,'0')='0' and ifnull(issue,'0')='1' and author=a.fansusername) as pnumber FROM umyfans a left join uuserinfo b on a.fansusername=b.username left join uuserdata c on a.fansusername=c.username where ifnull(b.Approval,'0')='0' and a.myusername='sam'连接数据库操作的用户的身份除了grant以外其它权限都有,mysql的版本为5.0.37,请问这个问题该如何解决?

解决方案 »

  1.   

    它说的是你的语句有错。你这个语句没有12这个字符啊,mysql报的不是这句的错误。
      

  2.   

    near   '-12   ,   12'   at   line   1 
    就是说在你的语句中在 ‘-12’ 的那里附近出错了,系统编译器认不出你的语句
      

  3.   

    仔细检查:
    near   '-12   ,   12'   at   line   1
      

  4.   

    代码中有很多sql语句,现在不知道是哪句出错了,'-12 , 12'这个是什么意思
      

  5.   

    就是你的语句里有这个.........这是你写上来的错误啊!你找一下你的sql语句那里有这个'-12,12'啦。没找到的话就是说连你写上来的出错提示都不对,我们怎么帮你啊?
      

  6.   

    2008-01-05 11:01:38 [http-80-Processor4] [ERROR] com.dao.Impl.uMyFansDaoImpl - 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 '-12 , 12' at line 1这个是完整的日志,uMyFansDaoImpl的代码中的sql语句并没有'-12 , 12',所以不明白是怎么回事
      

  7.   

    你手工在SQL上一条条的输入看看,不就能找到了:)