From: Markus Schaber <schabi@logix-tt.com>
To: Jeff Boes <jeff@endpoint.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Joins involving functions
Date: Tue, 11 Apr 2006 13:42:28 +0200
Message-ID: <443B9624.2020503@logix-tt.com> (raw)
In-Reply-To: <4436D343.5010802@endpoint.com>
References: <4436D343.5010802@endpoint.com>
Hi, Jeff Boes,
Jeff Boes wrote:
> select * from bar
> cross join f_foo(bar.b) as foo;
>
> Unfortunately, this last statement returns an error:
>
> NOTICE: adding missing FROM-clause entry for table "bar"
> ERROR: function expression in FROM may not refer to other relations of
> same query level
>
> Is there a method for joining function calls to tables? The only other
> approach I can think of is to write another function that returns "setof".
I don't exactly know what you want to achieve, so I'm just wildly guessing.
Do you really want the cross join between bar.* and f_foo(bar.b)?
If yes, use
SELECT x.b, y.b FROM bar x CROSS JOIN bar y;
If not, you maybe want
SELECT b, f_foo(b) FROM bar;
Or it may be you want something like:
SELECT * from bar CROSS JOIN (SELECT f_foo(bar.b) from bar) as foo ;
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: schabi@logix-tt.com, jeff@endpoint.com
Subject: Re: Joins involving functions
In-Reply-To: <443B9624.2020503@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox