5

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.

1
  • Like Yoda says, remove the extra "SET" bits. The syntax is UPDATE ... SET field=value, field=value, field=value Commented Jan 31, 2011 at 4:01

3 Answers 3

9
UPDATE users SET timezone = 'America/New_York', updates = 'NO', verified = 'YES' WHERE id = '1'
Sign up to request clarification or add additional context in comments.

Comments

4

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

Comments

0

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'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.