Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Update Multiple Columns Issue

Tags:

php

mysql

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.

like image 703
element119 Avatar asked Jan 31 '11 03:01

element119


2 Answers

UPDATE users SET timezone = 'America/New_York', updates = 'NO', verified = 'YES' WHERE id = '1'
like image 108
yoda Avatar answered Sep 17 '22 18:09

yoda


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

like image 37
Joko Wandiro Avatar answered Sep 19 '22 18:09

Joko Wandiro