SQLSyntaxErrorException: You have an error in your SQL syntax;
今天我在做一个根据用户id从数据库中删除数据的时候,出现以下错误。
java.sql.SQLSyntaxErrorException: 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 'where userId = 22' at line 1 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061)
我的关注点一直在where筛选条件上面,因此浪费了一些时间
经过一番细致的检查,我发现 delet后忘加from导致了,经过补充,问题解决。
总结:遇到此类问题时候,提示有问题的地方,不一定本身有问题,有可能是前方出错导致的。