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. ddos - apache日志很多其它网址,什么情况?2. boot2docker无法启动3. css - weui 用伪元素生成border,源码有点不理解4. java - list<Map<String, Object>> 排序5. javascript - 关于audio标签暂停的问题6. javascript - 调微信分享朋友接口,出现下面问题,求解答,7. webpack - vue-cli写的项目(本地跑没有问题),准备放到Nginx服务器上,有什么配置需要改的?还有怎么部署?8. 微信公众号发送模板消息返回错误410009. 这是什么情况???10. 问题Unknown column ’’ in ’where clause’
