X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7406311F61B8 for ; Tue, 11 Apr 2006 08:42:31 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id ApFIAJ1-n3w3 for ; Tue, 11 Apr 2006 08:42:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 254B711F6251 for ; Tue, 11 Apr 2006 08:42:18 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (Tb349.t.pppool.de [89.55.179.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 9E488656CB; Tue, 11 Apr 2006 13:43:10 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id D3EDC181520C4; Tue, 11 Apr 2006 13:42:28 +0200 (CEST) Message-ID: <443B9624.2020503@logix-tt.com> Date: Tue, 11 Apr 2006 13:42:28 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Boes Cc: pgsql-sql@postgresql.org Subject: Re: Joins involving functions References: <4436D343.5010802@endpoint.com> In-Reply-To: <4436D343.5010802@endpoint.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/80 X-Sequence-Number: 24889 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