Sample Header Ad - 728x90

Using column alias in a WHERE clause doesn't work

52 votes
4 answers
73962 views
Given a table users with two fields: id and email. select id, email as electronic_mail from ( select id, email from users ) t where electronic_mail = '' Postgres complains that: > ERROR: column "electronic_mail" does not exist The example is just to demonstrate the arising problem. My actual case is more complex, I iterate though an array of elements in a json column, taking a single scalar value from each. (I can share some code if that helps.) I really don't get what would be the complication, probably I'm unaware of something. I was under the impression that aliased columns can be employed in a WHERE clause without problem?
Asked by Victor (657 rep)
Dec 27, 2018, 06:24 PM
Last activity: Nov 30, 2023, 02:23 PM