Mysql写入数据的错误,很容易忽视掉!

先说错误,在写入数据库的时候一直报错“

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 'by agent_id,name ) as a' at line 2 [ SQL语句 ] 



最后发现一个很容易就忽视的问题,对我是这样,先看原句




在这里就发现问题了,如果把sql语句打印出来你会发现,在$where变量插入的地方是“.....where is_delete = 0order by......”,发现问题没,对,就是“...where is_delete = 0”和“order by...”之间没有空格,导致在MySQL中识别你的语句的时候报错,


所以只要在$where = "where is_delete = 0"之后加个空格变成$where = "where is_delete = 0 "


或者在引用$where变量的时候,后边和order之间加个空格就行。


解决!

猜你喜欢

转载自blog.csdn.net/jiahao791869610/article/details/72832758