MySQL Update
MySQL Update
MySQL update syntax and examples.
MySQL Update syntax
UPDATE table_name SET col1=val1;
UPDATE table_name SET col1=val1, col2=val2, col3=val3, … WHERE condition;
Table test
ID | NAME |
---|---|
1 | abc |
2 | def |
3 | ghi |
4 | jkl |
Update example
UPDATE test SET name = 'aaa'; UPDATE test SET id=22, name='bbb' WHERE id=2; UPDATE test SET name='ddd' WHERE id=4; SELECT * FROM test;
Query Result
ID | NAME |
---|---|
1 | aaa |
22 | bbb |
3 | aaa |
4 | ddd |