mysql update inner join錯誤
問題描述
問題解答
回答1:create table tb1( country int, province int, city int);create table tb2( country int, province int, city int);insert into tb1 (country, province, city) values (1, 2, 5), (1, 3, null);insert into tb2 (country, province, city) values (1, 2, 5), (1, 3, 7);select * from tb1;select * from tb2;update tb1inner join tb2 on tb1.country=tb2.country and tb1.province=tb2.provinceset tb1.city=tb2.citywhere tb1.city is null; -- and tb1.xx=?select * from tb1;select * from tb2;
update from 語句在 mssql 中有效, mysql 似乎無法正常執行
update tb1 set city=r.city from (select country, province, city from tb2) as rwhere tb1.city is null and tb1.country=r.country and tb1.province=r.province
http://sqlfiddle.com/#!9/4df7d7/2
相關文章:
1. android - 分享到微信,如何快速轉換成字節數組2. javascript - 能否讓vue-cli的express修改express重啟服務3. 解決Android webview設置cookie和cookie丟失的問題4. angular.js - Beego 與 AngularJS的模板格式沖突,該怎么解決?5. javascript - vue2.0中,$refs對象為什么用駝峰的方式獲取不到屬性?6. node.js - npm一直提示proxy有問題7. html5 - 有人做過防微信app界面的H5 demo嗎?8. javascript - 有沒有iOS微信中可以在背景播放視頻的方法?9. 最新版本的微信web開發者工具必須要APPID,會提供測試號,但是像你一樣tabBar配置的話不會顯示首頁與日志,難道我要下載跟你一樣的版本?10. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?
