MYSQL 中两个表的数据清洗问题


两个表分别都有两个相同的字段比如A表有cityId,cityName.B表也有cityId,cityName.
B表的cityId和cityName都有值。A表有大量数据cityId有值且值都包含在A表。cityName为空。如何去根据B表填充A表的cityName?

node.js mysql 数据清洗

天楼久那姬 9 years, 9 months ago

 sql


 UPDATE  a,  b SET a.cityName = b.cityName  WHERE a.cityId= b.cityId

永远D风雅 answered 9 years, 9 months ago

update A join B set A.cityName=B.cityName on A.cityId=B.cityId

我在你背后 answered 9 years, 9 months ago

Your Answer