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. javascript - 頁面滾動條出現時如何防止頁面跳動2. redis sentinel怎么跑守護進程以及日志記錄位置的?3. javascript - mongodb怎么設置用戶的賬戶不重復?4. android - 優酷的安卓及蘋果app還在使用flash技術嗎?5. DADB.class.php文件的代碼怎么寫6. javascript - onclick事件點擊不起作用7. HTML5禁止img預覽該怎么解決?8. mysqld無法關閉9. mysql - 數據庫:獲取兩個字段與獲取*,傳輸的數據量差距大嗎?10. javascript - "CommonsChunkPlugin now only takes a single argument.。。。。

網公網安備