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

4、编写语句,同时更新id和value两个字段;update test_update_cols set id = id+100, value = concat(value,'00');5、编写语句,重新查询数据,可以发现两个字段已经被更新;select t.* from test_update_cols t;
mysql中怎么修改多个字段的数据
:update 表名称 set 属性1=?,属性2=? where id=? 这里的id值得是你表的主键,他的值是想要修改的那条记录的主键值2017-08-21
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;

2020-02-06
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'
WHERE LastName = 'Wilson'2017-08-21
update 表名称 set 属性1=?,属性2=? where id=? 这里的id值得是你表的主键,他的值是想要修改的那条记录的主键值2017-08-21
mengvlog 阅读 55 次 更新于 2025-12-17 00:00:07 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部