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. 如何解决docker宿主机无法访问容器中的服务?2. javascript - 微信jssdk ios下自定义onMenuShareAppMessage 分享失效,Android分享成功3. 老师百度网盘分享一下WampServer的包啊,我们下载几kb要下载一天的.4. java - 如图,同样一个表单,为什么用myeclipse内置的浏览器提交就会自动编码,用chrome浏览器就不会自动编码?5. node.js - windows下安装webpack时出现路径问题如何解决?6. SQLAlchemy 访问Mysql数据库弹出Warning,VARIABLE_VALUE,如何解决?7. php study 安装 composer 用不了8. vue.js - weex 没有背景图片属性怎么办?9. html - css中怎么命名颜色比较好?10. 关于java 泛型设计接口 导致的参数类型不匹配问题
