mysql中怎么修改多个字段的数据

如题所述

1、创建测试表,

create table test_update_cols(id int,value varchar(20));

2、插入测试数据;

insert into test_update_cols values (1,'v1');

insert into test_update_cols values (2,'v2');

insert into test_update_cols values (3,'v3');

insert into test_update_cols values (4,'v4');

3、查询表中全量数据;select t.* from test_update_cols t;

4、编写语句,同时更新id和value两个字段;

   update test_update_cols set id = id+100, value = concat(value,'00');

5、编写语句,重新查询数据,可以发现两个字段已经被更新;select t.* from test_update_cols t;

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-08-21
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'
WHERE LastName = 'Wilson'
第2个回答  2017-08-21
update 表名称 set 属性1=?,属性2=? where id=? 这里的id值得是你表的主键,他的值是想要修改的那条记录的主键值
第3个回答  2017-08-21
:update 表名称 set 属性1=?,属性2=? where id=? 这里的id值得是你表的主键,他的值是想要修改的那条记录的主键值本回答被提问者采纳
相似回答