表结构:
表
往表中插入一条记录
结果集
执行一下sql
在查看下表的结果
money字段变成负数,这是不正确结果,期望是money最小值是0,小了就不能再减,
正确sql如下
update walletset money =money -19 where id =1 and money >=19
表结构:
往表中插入一条记录
执行一下sql
在查看下表的结果
money字段变成负数,这是不正确结果,期望是money最小值是0,小了就不能再减,
正确sql如下
update walletset money =money -19 where id =1 and money >=19