我想这样做:
UPDATE `data` d
SET map_lat, map_lon =
(SELECT latitude, longitude FROM `maps_city` c WHERE c.zipcode = d.zipcode)
如何使用SQL进行操作?
由于
答案 0 :(得分:2)
你有没有试过像
这样的东西UPDATE `data` d, `maps_city` c
SET d.map_lat = c.latitude,
d.map_lon = c.longitude
WHERE c.zipcode = d.zipcode
查看UPDATE Syntax并查找多表语法
答案 1 :(得分:1)
Mysql支持多表更新, 语法如
UPDATE
data, maps_city
SET
data.map_lat=maps_city.latitude,
data.map_lon=maps_city.longitude
WHERE
data.zipcode=maps_city.zipcode