写法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);

解决方案 »

  1.   

    我知道了,我只能用第二种,其他无法保证事务
    还是谢谢狼头
    B是一个表,和A有外键关联的,联合一下能实现第二种写法的效果第二种写法其实要先去B表里读条件的,但是因为B表使我们自己做的缓存,所以不会给数据库压力想问的其实就是
    第一种联合了一下
    第二种省掉了联合的操作,但是是6次
      

  2.   

    如果是第一次执行  那么建议你用第二种方法可以知道每个update锁消耗的时间,也就没有了长时间执行不出来等待的慌张