如何设置一个表的多列使用更新查询在mysql?


当前回答

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

其他回答

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

只需添加参数,用逗号分隔:

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

参见mySQL手册中的UPDATE

让我们举一个例子,其中您有一个people表,您想要更新id等于5的人的年龄和姓名列。查询如下所示:

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