Re: Alias in WHERE clause - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Alias in WHERE clause
Date
Msg-id 200005201137.HAA15792@candle.pha.pa.us
Whole thread Raw
In response to Alias in WHERE clause  ("Eric Jain" <jain@gmx.net>)
List pgsql-general
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I would like to be able to say:
>
> SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles
> WHERE score > 0
> ORDER BY score DESC;
>
> This returns: ERROR:  Attribute 'score' not found.

We just don't support aliases in WHERE, as you suggest.  I see your
problem if score_a is complicated.  The issue is that the target list is
not evaluated until _after_ the WHERE clause.

--
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: rules on INSERT can't UPDATE new instance?
Next
From: Bruce Momjian
Date:
Subject: Re: Re: [HACKERS] Postgresql OO Patch