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. 將SQLServer數據同步到MySQL 用什么方法?2. 為什么我ping不通我的docker容器呢???3. android - webview 自定義加載進度條4. docker安裝后出現Cannot connect to the Docker daemon.5. numpy - python [:,2][:,None]是什么意思6. javascript - 微信小程序封裝定位問題(封裝異步并可能多次請求)7. 并發模型 - python將進程池放在裝飾器里為什么不生效也沒報錯8. javascript - 微信小程序限制加載個數9. javascript - 微信音樂分享10. python 怎樣用pickle保存類的實例?
