Postgres column does not exist, but it is there with an alias

I have a generated Postgres request

select ..., s.name as supplier, ... from ... supplier s ... where ... AND (cast(supplier as varchar(255)) ilike '%test%') ... ORDER BY supplier desc nulls last 

I get this error:

org.postgresql.util.PSQLException: ERROR: provider column does not exist

if I replaced the "provider" with s.name, then that’s fine, but I can’t do this. I have this problem on other columns as well, but there are columns that work fine.

There are some limitations that I cannot use an alias in the same way as a table name or what could be the problem?

+5
source share
1 answer

I found an explanation here: http://www.postgresql.org/message-id/ 18195.1038530280@sss.pgh.pa.us

I cannot use the alias from select in the WHERE clause.

+5
source

All Articles