/ / Неизвестна колона "a1.location" в "where clause" - mysql

Неизвестна колона "a1.location" в "where clause" - mysql

Опитвам се да изпълня тази заявка

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;

Но im получаване "Неизвестна колона" 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;

Помощ, моля

Отговори:

1 за отговор № 1

По-добър начин да го направите би бил използването на присъединете се

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;

0 за отговор № 2

Опитай.

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;