1. 程式人生 > >You have an error in your SQL syntax錯誤解決方案

You have an error in your SQL syntax錯誤解決方案

在寫javaweb實驗時出現了這個問題:

具體問題如下:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'id=4' at line 1

也就是說在sql語句出現錯誤,在sql語句的第一行的‘id=4’附近。

這時候可以看到這個語句的user_name,age,sex,id並不是一些mysql內部關鍵字。

在sql語句中更新語句就是:

update  tbl_user_info

set  user_name=?,age=?,sex=?

where id=?

所以就是在“sex=?”+“ where id=?”加上一個空格就好。

或者