Re: filtering after join

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: andrew <andrew(dot)ylzhou(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: filtering after join
Date: 2006-01-25 17:53:38
Message-ID: 20060125175338.GA76400@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Jan 25, 2006 at 06:27:33PM +0100, andrew wrote:
> I want to use a UDF to filter tuples t that are generated after a join.
> More specifially, I have a UDF foo(record), which computes a value for
> a given tuple. I can do the filtering before the join. e.g.:
>
> select * from A, B where foo(A)<2 and A.a=B.b;
>
> But I want to apply foo() to the tuples generated by the join
> operation. How can I do that?

Is this what you're looking for?

select *
from (select * from A, B where A.a = B.b) as s
where foo(s) < 2;

--
Michael Fuhr

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2006-01-25 19:11:13 Re: filtering after join
Previous Message Owen Jacobson 2006-01-25 17:43:49 Re: psql in the command line