gpt4 book ai didi

mysql - 'a1.location' 中的未知列 'where clause'

转载 作者:行者123 更新时间:2023-11-29 12:17:16 26 4
gpt4 key购买 nike

我正在尝试执行此查询

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com