Search code examples
mysqlsql-updateprepared-statementconcatenation

How to update MySQL text column with concat with a prepared statement?


I am trying to concatenate a text column with UPDATE in my database but I am unable to find any resouces online that explain how to do with a prepared statement. I keep getting an error:

syntax to use near '(admin_notes=?) WHERE id=?' at line 1

UPDATE problem_report SET concat(admin_notes=?) WHERE id=?

Solution

  • You are trying to UPDATE the admin_notes column. You need to concat the value not the column itself.

    UPDATE problem_report SET admin_notes = concat(admin_notes,?) WHERE id=?