所以我在phpMyAdmin中使用SQL。现在我想用一个准备好的语句对我的数据库进行更新,但是它会给我以下错误:
com.mysql.jdbc.exceptions.jdbc4.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 'autor='Lol' WHERE id=44' at line 1
这就是我的陈述的样子:
command = connection.prepareStatement("UPDATE books SET name=? author=? WHERE id=?");
command.setString(1, name.getText());
command.setString(2, author.getText());
command.setInt(3, IDx);
command.execute();
Wat我做的陈述错了吗?它应该工作在我看来。
答案 0 :(得分:2)
您需要使用以下逗号分隔更新的字段:
command = connection.prepareStatement("UPDATE books SET name=?, author=? WHERE id=?");
答案 1 :(得分:1)
您在author
UPDATE books
SET name = ?, author = ?
WHERE id = ?