1

我收到错误 ERROR: 在“(”处或附近出现语法错误

String deleteSQL = "DELETE FROM customer" +
"WHERE (fname = 'Fred' AND lname = 'Flintstone')" +
"OR (fname = 'Barney' AND lname = 'Rubble')";
System.out.println("Records deleted: "
+ stmt.executeUpdate(deleteSQL));
4

1 回答 1

5
String deleteSQL = "DELETE FROM customer " +
"WHERE (fname = 'Fred' AND lname = 'Flintstone') " +
"OR (fname = 'Barney' AND lname = 'Rubble') ";
System.out.println("Records deleted: "
+ stmt.executeUpdate(deleteSQL));

问题是连接时缺少空格

想象一下:

“单词”+“单词2”

这将导致 "wordword2"

所以应该是

"word" + " " + "word2" 或者 "word "+ "word2"

于 2013-11-02T13:39:59.657 回答