Alias in WHERE clause

From: "Eric Jain" <jain(at)gmx(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Alias in WHERE clause
Date: 2000-05-20 09:32:13
Message-ID: NCBBJFHBEGOIAHBCBNCLAEPJCEAA.jain@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

The following works:

SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles
WHERE score_a(text, CAST('term' AS TEXT)) > 0
ORDER BY score DESC;

Doesn't seem efficient to me? Or are the results from score_a cached
somehow?

score_a is a (rather computation-intensive :-) PL/Perl function which
returns an integer.

I am using PostgreSQL 7.0

--
Eric Jain

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthias Urlichs 2000-05-20 10:14:38 Re: Performance (was: The New Slashdot Setup (includes MySql server))
Previous Message Giles Lean 2000-05-20 09:31:03 Re: Columns in pg_shadow?