MySQL批量更新

由于mysql没有top函数,limit也不支持子查询,所以批量修改、查询就显得比较麻烦,

但是我还是想到了一个办法;

即创建一个临时表,用于批量操作;

详细如下:

1 create TEMPORARY TABLE test(cardId VARCHAR(50) not NULL);
2 INSERT into test select cardId from dsos_live_memberuser ORDER BY cardId LIMIT 60,10;
3 
4 UPDATE dsos_live_memberuser set linkedChain = 'xs1103' , linkedStore = 'code002' 
5 where cardId in (select * from test );
6 
7 drop table test;

如图:

运行效果:

喜欢的童鞋点个赞吧~~~~~

原文地址:https://www.cnblogs.com/zgq7/p/10831138.html