我正在尝试执行此查询
UPDATE airport AS a1,
(SELECT location_ar
FROM airport as a3
WHERE a3.location = a1.location AND a3.location_ar != NULL LIMIT 1) as a2
SET a1.location_ar = a2.location_ar WHERE a1.location = NULL;
但即时通讯"未知专栏' a1.location'在' where子句'",
已编辑:新查询为:
UPDATE airport AS a1, (SELECT location_ar FROM airport WHERE location = a1.location AND a3.location_ar != NULL LIMIT 1) as a2 SET a1.location_ar = a2.location_ar WHERE a1.location = NULL;
请帮助
答案 0 :(得分:1)
更好的方法是使用join
update airport a1
join airport a2 on a1.location = a2.location and a2.location_ar is not NULL
set a1.location_ar = a2.location_ar
where a1.location is NULL;
答案 1 :(得分:0)
试试吧。
UPDATE airport AS a1,
(SELECT location_ar FROM airport as a3
WHERE a3.location = airport.location
AND a3.location_ar is not NULL LIMIT 1) as a2
SET a1.location_ar = a2.location_ar
WHERE a1.location is NULL;