写法1
update a inner join b on a.xx=b.xx set a.y=a.y-1;
6 rows affect写法2
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;写法3
update a set a.y=a.y-1 where a.xx in (1,2,33,49,5,6);
update a inner join b on a.xx=b.xx set a.y=a.y-1;
6 rows affect写法2
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;
update a set a.y=a.y-1 where a.xx=?;写法3
update a set a.y=a.y-1 where a.xx in (1,2,33,49,5,6);
还是谢谢狼头
B是一个表,和A有外键关联的,联合一下能实现第二种写法的效果第二种写法其实要先去B表里读条件的,但是因为B表使我们自己做的缓存,所以不会给数据库压力想问的其实就是
第一种联合了一下
第二种省掉了联合的操作,但是是6次