文章詳情頁
mysql如何根據各自條件批量更新
瀏覽:77日期:2022-06-10 18:57:43
問題描述
現有兩張表,A是明細表id uid cost
0
1
4
3
現在要把把該表中cost大于0的數據,根據uid分組然后更新到另一個表上
select uid,count(cost) as count from A group by uid where cost > 0
這是取出的語句,有沒辦法一句話把這個查詢結果根據uid更新到另一張表上?
問題解答
回答1:update B b set b.col=(select count(a.cost) as count from A a where cost > 0 and a.uid=b.uid group by uid)
相關文章:
1. macos - mac下docker如何設置代理2. java - 請問在main方法中寫成對象名.屬性()并賦值,與直接參參數賦值輸錯誤是什么原因?3. MySQL數據庫中文亂碼的原因4. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””5. docker不顯示端口映射呢?6. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?7. android studio總是在processes running好久8. angular.js - 關于$apply()9. docker-compose 為何找不到配置文件?10. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下
排行榜
