begin
for i in 1 .. 100000
loop
update a set a.1=x where a.2=i
if mod(i,5000)=0
then
commit
end if
end loop
end
/
update [tablename] set status = 1 where id=1 or id=2 or id=3 or id=4update [tablename] set status = 1 where id between 1 and 4 update [tablename] set status = 1 where id in (数组的值)MySQL没有提供直接的方法来实现批量,但可以使用case when语法来实现这个功能。UPDATE course
SET name = CASE id
WHEN 1 THEN 'name1'
WHEN 2 THEN 'name2'
WHEN 3 THEN 'name3'
END,
title = CASE id
WHEN 1 THEN 'New Title 1'
WHEN 2 THEN 'New Title 2'
WHEN 3 THEN 'New Title 3'
END
WHERE id IN (1,2,3)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)