相关疑难解决方法(0)

在MySQL查询的WHERE子句中使用列别名会产生错误

我正在运行的查询如下,但是我收到此错误:

#1054 - 'IN/ALL/ANY子查询'中的未知列'guaranteed_postcode'

SELECT `users`.`first_name`, `users`.`last_name`, `users`.`email`,
SUBSTRING(`locations`.`raw`,-6,4) AS `guaranteed_postcode`
FROM `users` LEFT OUTER JOIN `locations`
ON `users`.`id` = `locations`.`user_id`
WHERE `guaranteed_postcode` NOT IN #this is where the fake col is being used
(
 SELECT `postcode` FROM `postcodes` WHERE `region` IN
 (
  'australia'
 )
)
Run Code Online (Sandbox Code Playgroud)

我的问题是:为什么我无法在同一个数据库查询的where子句中使用假列?

mysql sql mysql-error-1054

183
推荐指数
5
解决办法
18万
查看次数

标签 统计

mysql ×1

mysql-error-1054 ×1

sql ×1