/ / Nieznana kolumna "a1.location" w "where clause" - mysql

Nieznana kolumna "a1.location" w "where clause" - mysql

Próbuję wykonać to zapytanie

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;

Ale otrzymuję "Nieznaną kolumnę" a1.location "w" gdzie klauzula "",

Edytowane: nowe zapytanie to:

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;

Prosimy o pomoc

Odpowiedzi:

1 dla odpowiedzi № 1

Lepszym sposobem na to byłoby użycie 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;

0 dla odpowiedzi nr 2

Spróbuj.

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;