0

I'm trying to execute the sql query:

INSERT INTO celebrity (name, `1`, `15`, `3`, `20`, `4`, `13`, `35`, `22`, `6`, `19`) VALUES ("Keith Allen", 1, 1, 1, 1, 1, -1, -1, -1, -1, 1)

which worked fine in the workbench and correctly added the new row, however when I call the same query from java using the executeUpdate(String query) method, I get a sql syntax error

2
  • 1
    can you try 'Keith Allen' Commented Mar 30, 2015 at 6:53
  • The ` character is there so sql can tell that 1 is the name of a column and not just an integer. I was using ' before and I was getting syntax errors Commented Mar 30, 2015 at 7:08

1 Answer 1

2

You need to escape your double quotes like this:

INSERT INTO celebrity (name, `1`, `15`, `3`, `20`, `4`, `13`, `35`, `22`, `6`, `19`)
VALUES (\"Keith Allen\", 1, 1, 1, 1, 1, -1, -1, -1, -1, 1)
Sign up to request clarification or add additional context in comments.

Comments

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.