MySQL高级转账案例
-- 任务 2-1:使用 update 语句实现转账操作,实现账号 1 向账号 2 转账 100 元。
create table t_act(
acton int not null,
balance int not null
);
insert into t_act(acton,balance)
values(1,500),
(2,100);
create table t_act(
acton int not null,
balance int not null
);
insert into t_act(acton,balance)
values(1,500),
(2,100);
update t_act set balance=balance-100 where acton=1;
update t_act set balance=balance+100 where acton=2;
update t_act set balance=balance+100 where acton=2;
浙公网安备 33010602011771号