To update multiple columns use the SET clause to specify additional columns. Just like with the single columns you specify a column and its new value, then another set of column and values. In this case each column is separated with a column.
Note that the UPDATE statement allows you to update as many columns as you want.
Can we UPDATE multiple tables with a single SQL query? No, only 1 table can be updated with an UPDATE statement. However, you can use a transaction to ensure that 2 or more UPDATE statements are processed as a single unit-of-work.
MySQL UPDATE command can be used to update multiple columns by specifying a comma separated list of column_name = new_value. Where column_name is the name of the column to be updated and new_value is the new value with which the column will be updated.
Just add parameters, split by comma:
UPDATE tablename SET column1 = "value1", column2 = "value2" ....
See also: mySQL manual on UPDATE
UPDATE some_table
SET this_column=x, that_column=y
WHERE something LIKE 'them'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With