当前位置: 代码迷 >> SQL >> sql语句换行的有关问题
  详细解决方案

sql语句换行的有关问题

热度:41   发布时间:2016-05-05 12:21:34.0
sql语句换行的问题

今天在执行SQL语句时发现错误,

SQL语句是这样的:

sql = "select s_dayreport.* from s_dayreport inner join s_subuser on s_dayreport.userId = s_subuser.userId where s_subuser.mgrId = "+id+" and s_subuser.userId =						"+subUserId+" " +					"order by taskDate desc" +						"limit "+firstResult+","+maxResults+" ";


出现错误,


仔细看了下,没错啊。继续检查,把SQL语句放在SQLYOG中执行,错误提示如下:

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 'desclimit 0,13  LIMIT 0, 1000' at line 1

原来,我在换行的时候desc后并没有留空格,在一行时还容易被发现,换行后很容器被骗到

在desc后打一个空格,解决问题。

  相关解决方案