Skip to content
Advertisement

Update columns in MySQL depending on cell value

I want to update multiple cells in a MySQL table depending on value.

I find that if I take a field called engagement I can update it one at a time like so:

However, if I try to do multiple at a time it fails and I get an error:

ERROR 1064 (42000): 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 ‘SET Engagement=’800000039768′ WHERE Engagement IS NULL and LinkedAccountId = ’30’ at line 1

Is it incorrect to use AND between these statements? What am I doing wrong?

Advertisement

Answer

You can do it with a CASE statement:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement