How to set multiple columns of a table using update query in mysql?
3 Answers
Just add parameters, split by comma:
UPDATE tablename SET column1 = "value1", column2 = "value2" ....
See also: mySQL manual on UPDATE
-
1
-
1@71GA I don't think so. That sounds like something you'd need two different statements for.– PekkaSep 22, 2017 at 22:18
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