我正在尝试执行此查询
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;
但是我收到“'where 子句'中的未知列'a1.location'”,
编辑:新查询是:
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;
请帮忙
最佳答案
更好的方法是使用 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;
关于mysql - 'a1.location' 中的未知列 'where clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29609721/