setting multiple column using one update

Mysql

Mysql Problem Overview


How to set multiple columns of a table using update query in mysql?

Mysql Solutions


Solution 1 - Mysql

Just add parameters, split by comma:

UPDATE tablename SET column1 = "value1", column2 = "value2" ....

See also: mySQL manual on UPDATE

Solution 2 - Mysql

UPDATE some_table 
   SET this_column=x, that_column=y 
   WHERE something LIKE 'them'

Solution 3 - Mysql

Let's take an example where you have a people table and you would like to update the age and the name column for the person with id equals to 5. The query will look like this:

UPDATE people SET age = 34, name = "John" WHERE id = 5

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmoghView Question on Stackoverflow
Solution 1 - MysqlPekkaView Answer on Stackoverflow
Solution 2 - MysqlHendra JayaView Answer on Stackoverflow
Solution 3 - MysqlRan TurnerView Answer on Stackoverflow