1

I get error ERROR: syntax error at or near "("

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
  • 3
    You need to put spaces between customer and WHERE. Commented Nov 2, 2013 at 13:38
  • No space between closing bracket and OR Commented Nov 2, 2013 at 13:38
  • +1 for the names used :p Commented Nov 2, 2013 at 13:45
  • You could have easily solved this problem yourself my merely examining deleteSQL with the debugger. Commented Nov 2, 2013 at 13:58

1 Answer 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));

The problem are the missing spaces while concatinating.

Imagine the following:

"word" + "word2"

this would result "wordword2"

so it should be

"word" + " " + "word2" or "word "+ "word2"

Sign up to request clarification or add additional context in comments.

1 Comment

Jup. That was it :) +

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.