我收到错误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));
最佳答案
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));
问题是连接时缺少空格。
想象一下以下内容:“ word” +“ word2”
这将导致
"wordword2"
所以应该
"word" + " " + "word2"
或"word "+ "word2"