집 > Q&A > 본문
两个表分别都有两个相同的字段比如A表有cityId,cityName.B表也有cityId,cityName. B表的cityId和cityName都有值。A表有大量数据cityId有值且值都包含在A表。cityName为空。如何去根据B表填充A表的cityName?
怪我咯2017-04-17 13:06:59
update A join B set A.cityName=B.cityName on A.cityId=B.cityId
高洛峰2017-04-17 13:06:59
sqlUPDATE a, b SET a.cityName = b.cityName WHERE a.cityId= b.cityId
sql
UPDATE a, b SET a.cityName = b.cityName WHERE a.cityId= b.cityId