mysql update inner join錯(cuò)誤
問題描述
問題解答
回答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
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. css - 寫頁面遇到個(gè)布局問題,求大佬們幫解答,在線等,急!~4. 配置Apache時(shí),添加對(duì)PHP的支持時(shí)語法錯(cuò)誤5. phpstudy8.1支持win11系統(tǒng)嗎?6. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問7. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?8. 實(shí)現(xiàn)bing搜索工具urlAPI提交9. Apache 已經(jīng)把網(wǎng)站根目錄的改為allow from all了,但是服務(wù)器還是不能訪問?10. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化

網(wǎng)公網(wǎng)安備