在写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=?”加上一个空格就好。
![]()
或者
![]()
本文解决了一个在JavaWeb实验中遇到的SQL语法错误问题,详细解释了在更新语句中id=4附近的错误,并提供了正确的SQL语句格式,即在sex=?和where id=?之间添加一个空格。
1万+





