msql常用语句(批量更新)

1.批量插入

insert into 表名[(字段列表)]
values(值列表1),(值列表2),...(值列表n);
例如:
insert into students(sid,sname,dob) values
('001','张三','2001-02-03'),
('002','李四','2002-02-03'),
('003','王五','2003-02-03');

 2.批量更新

update student SET stu_name =
CASE 
 id
 WHEN 111 THEN CONCAT(stu_name,'_no1')
 WHEN 222 THEN CONCAT(stu_name,'_no2')
END
WHERE id IN (111,222)

 

posted @ 2022-12-07 11:23  N神3  阅读(55)  评论(0编辑  收藏  举报