From: Aaron Bono <postgresql@aranya.com>
To: emilu@encs.concordia.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: Is it possible to left join based on previous joins result
Date: Sat, 9 Sep 2006 12:26:10 -0500
Message-ID: <bf05e51c0609091026r77ba3973hcd1d73556723a5a6@mail.gmail.com> (raw)
In-Reply-To: <45002689.9050307@encs.concordia.ca>
References: <45001AF6.4020706@encs.concordia.ca>
<45002689.9050307@encs.concordia.ca>
On 9/7/06, Emi Lu <emilu@encs.concordia.ca> wrote:
>
> I tried the example as the following:
>
> create table a(col1);
> create table b(col1, col2)
>
> select a.*
> from a inner join b using(col2)
> left join b.col2 as c on (c.col1 = a.col1)
>
> System notifies me that b is not a schema name.
>
> So, I guess the approach that I tried to do is not acceptable by Pgsql
> grammar.
the syntax is
LEFT JOIN [table] AS ...
you have b.col2 which means the database will interpret col2 as the table
name and subsequently b as the schema name
You should have
SELECT a.*
FROM a
INNER JOIN b using(col2)
LEFT JOIN b as c on (c.col1 = a.col1)
In the "using(col2)", what columns and tables are you joining there? I
always dislike that syntax as it is ambiguous in some cases and not very
easy to read.
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.comhttp://codeelixir.com
==================================================================
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: postgresql@aranya.com, emilu@encs.concordia.ca
Subject: Re: Is it possible to left join based on previous joins result
In-Reply-To: <bf05e51c0609091026r77ba3973hcd1d73556723a5a6@mail.gmail.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