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. macos - mac下docker如何设置代理2. java - 请问在main方法中写成对象名.属性()并赋值,与直接参参数赋值输错误是什么原因?3. MySQL数据库中文乱码的原因4. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””5. docker不显示端口映射呢?6. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?7. android studio总是在processes running好久8. angular.js - 关于$apply()9. docker-compose 为何找不到配置文件?10. dockerfile - 我用docker build的时候出现下边问题 麻烦帮我看一下
