在WHERE子句中引用列名别名 [英] Refer to a column name alias in the WHERE clause

查看:135
本文介绍了在WHERE子句中引用列名别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Postgres sql中用列别名记录了此查询,它工作正常:

I have written down this query in postgres sql with column alias it is working fine:

select email as e from users 

它在 e 列别名下显示结果但是当我用 e 触发 where 条件时,它显示此错误:

It displays me result under e column alias but when I fire where condition with e then it shows this error:

select email as e from users where e = 'jaskaransingh@demo.com'




错误:列 e不存在

ERROR: column "e" does not exist

为什么?

推荐答案

其中被评估的地方在 select 之前,因此您不能使用在 where select 中声明的别名。 c $ c>子句。

where is evaluated before select, so you can't use alias declared in select in where clause.

这篇关于在WHERE子句中引用列名别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆