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 似乎無法正常執(zhí)行
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. angular.js - Angular路由和express路由的組合使用問題2. 網(wǎng)絡傳輸協(xié)議 - 以下三種下載方式有什么不同?如何用python模擬下載器下載?3. 我在centos容器里安裝docker,也就是在容器里安裝容器,報錯了?4. 表單提交驗證,沒反應,求老師指點5. 我的html頁面一提交,網(wǎng)頁便顯示出了我的php代碼,求問是什么原因?6. 如何修改phpstudy的phpmyadmin放到其他地方7. tp6表單令牌8. node.js - gulp文件監(jiān)聽的問題9. php - mysql中,作為主鍵的字段,用int類型,是不是比用char類型的效率更高?10. java 排序的問題
