MYSQL加入+;代替

MYSQL加入+;代替,mysql,join,replace,Mysql,Join,Replace,需要帮助生成查询以替换与第二个表匹配的表上的字段 表1 city 表2 city | code 我需要将表1中出现的所有城市替换为与城市字段匹配的表2代码 更新表1 t1集合t1.city=t2.code(来自表2 t2,其中t1.city)= t2.城市 实际上,不需要更换: UPDATE table1 JOIN table2 ON table1.city = table2.city SET table1.code = table2.code

需要帮助生成查询以替换与第二个表匹配的表上的字段

表1

city
表2

city | code

我需要将表1中出现的所有城市替换为与城市字段匹配的表2代码

更新表1 t1集合t1.city=t2.code(来自表2 t2,其中t1.city)= t2.城市


实际上,不需要更换:

UPDATE table1 JOIN table2 ON table1.city = table2.city SET table1.code = table2.code