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. 跟著課件一模一樣的操作使用tp6,出現了錯誤2. PHP類屬性聲明?3. css - 手機瀏覽器的兼容問題,微信和其它下載的瀏覽器打開沒有問題,谷歌也測試過,就是手機自帶的瀏覽器有問題。4. 前端 - 應該先從angularJS , vue.js , react 這些框架中的哪個開始入手?5. css - div外層有一圈白色6. css - 這些字體是怎么弄的?7. css3 - IE678兼容last-child的方法 請教8. transform - css3 translate 的水平垂直居中問題求解9. android - 關于百度定位的問題10. 微信小程序支持跳轉到外部鏈接網頁嗎
