2

I am trying to update a database via an update query,but I am getting an error that says

Error 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 'add=null,col=null,wok=null,pcol=null,pwok=null,bio=null where un ='null'' at line 1.

I have been trying for hours to figure out what the error is in my SQL Syntax,but I haven't been able to get through.

The update query is:

query = "Update users SET em=?, mn=?,add=?,col=?,wok=?,pcol=?,pwok=?,bio=? where un ='"+un+"'";

I need help in figuring out the error in my update syntax,Thanks.

Omiye Jay Jay
  • 409
  • 5
  • 10
  • 19

3 Answers3

1

ADD is a reserved word in mysql use backticks

\`add\`=?

http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-5.html

Mihai
  • 26,325
  • 7
  • 66
  • 81
1

ADD is reserved word. Please quote it or change field name

Joe Taras
  • 15,166
  • 7
  • 42
  • 55
1

From Reserved Words

the word add is a reserved keyword

Reserved words are permitted as identifiers if you quote them as described in Section 9.2, “Schema Object Names”:

From Schema Object Names

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it.

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284