Cocest
Cocest

Reputation: 146

Error using mysql update

I'm having problem to update data. I used preparedstatement to pass values to this:

"UPDATE Employee SET  " + name + "  =  ?  WHERE Employee_ID  =  ?"

This is the exception, "you have an error in your sql syntax".

Upvotes: 0

Views: 85

Answers (1)

Ankit Kansal
Ankit Kansal

Reputation: 84

In your given query the +name+ seems to be variable only then it must matches the column name in the underlying table as i have taken Employee. If the column does not exists then it'll throw an exception.

"UPDATE Employee SET col_name(table column name) = ? Where Employee_Id = ?"

Upvotes: 1

Related Questions