element119
element119

Reputation: 7625

MySQL Update Multiple Columns Issue

This seems to be a really simple query, but somehow I keep getting errors...

Basically, I just got a bunch of information from a user, and now I'm going to update their record in the users table in one query:

UPDATE users SET timezone = 'America/New_York', SET updates = 'NO', SET verified = 'YES' WHERE id = '1'

However, after running that, I get the following error: "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 updates = 'NO', SET verified = 'YES' WHERE id = '1'' at line 1".

Any help is much appreciated.

Upvotes: 5

Views: 5522

Answers (3)

bsanneh
bsanneh

Reputation: 521

Set have to be used once no matter how many columns you are updating .your query will be :-

UPDATE users SET timezone = 'America/New_York', updates = 'NO',verified = 'YES' WHERE id = '1'

Upvotes: 0

Joko Wandiro
Joko Wandiro

Reputation: 1987

Your update syntax is wrong, you have to write syntax SET just once.

UPDATE users SET col1= value1, col2= value2, col3= value3 WHERE condition;

More information about update UPDATE MANUAL

Upvotes: 4

yoda
yoda

Reputation: 10981

UPDATE users SET timezone = 'America/New_York', updates = 'NO', verified = 'YES' WHERE id = '1'

Upvotes: 9

Related Questions