mysql中update實現子查詢的方法
生活随笔
收集整理的這篇文章主要介紹了
mysql中update實現子查詢的方法
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
錯(cuò)誤:
1 update account_list2 set PaidIn = select sum(Penalty) from pay_rec where CerID = '1006840113' and Processed = 0,
3 Way = '現(xiàn)金'
4 where PaidIn = 0.00;
?
正確:
1 update account_list a,2 (select sum(Penalty) as P from pay_rec where CerID = '1006840113' and Processed = 0 group by Processed) b
3 set a.PaidIn = b.P,
4 a.Way = '現(xiàn)金'
5 where a.BillID = '20120102160851';
轉(zhuǎn)載于:https://www.cnblogs.com/alex4814/archive/2012/01/02/2310318.html
與50位技術(shù)專家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的mysql中update實現子查詢的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: PHP中上传文件文件名乱码
- 下一篇: 快春运了,做个火车余票查询接口,余票来源