写出银行模拟系统的取款业务对应的SQL语句

1. 2012年2月18日 张三 从账户‘77777777’中取出现金200元
2. 2012年2月19日 张三 从账户‘77777777’中转出300元到账户‘99999999’中

1. update Customer_Balance set balance = balance - 200 where card_id = '77777777'
insert into BillingHistory(card_id, amount, billing_date) values ('77777777', -200, '2012-02-18')
2. update Customer_Balance set balance = balance - 300 where card_id = '77777777'
update Customer_Balance set balance = balance + 300 where card_id = '99999999'
insert into BillingHistory(card_id, amount, billing_date) values ('77777777', -300, '2012-02-19')

insert into BillingHistory(card_id, amount, billing_date) values ('99999999', 300, '2012-02-19')

这样可以吗,加入一张表示客户余额表,一张表示存取历史表
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网