Re: Complex outer joins?

From: "Correia, Carla" <Carla(dot)Correia(at)logicacmg(dot)com>
To: "'Peter Childs'" <blue(dot)dragon(at)blueyonder(dot)co(dot)uk>
Cc: "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Complex outer joins?
Date: 2003-03-24 10:56:01
Message-ID: 0F232CC93A58D6119C1600B0D0799B8102338823@hamsrvmx03.logica.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Sorry if I was not that clear...but in fact the (+) is the join operator in
Oracle.
The statement in question is about making 3 left outer joins on 3 diferent
tables.
G, L and C are in fact 3 diferent tables.

Carla

-----Ursprüngliche Nachricht-----
Von: Peter Childs [mailto:blue(dot)dragon(at)blueyonder(dot)co(dot)uk]
Gesendet: Monday, March 24, 2003 11:44 AM
Cc: 'pgsql-sql(at)postgresql(dot)org'
Betreff: Re: [SQL] Complex outer joins?

On Mon, 24 Mar 2003, Correia, Carla wrote:

>
> Hi,
>
> I've got PsotgreSQL 7.3.
>
> My problem is joins. I've seen the syntax on joins and have sucessefully
> used SQLs with joins, but I've got some other big SQL statements using
many
> and complex
> joins.
> Simplified example:
>
> select G.SELID, G.TEXT,
> L.ID as SELLEVELID , L.SELLEVEL, L.LEVELJOIN, L.LEVELTEXT,
> C.ID as KRITERIENFELDID, C.SELFLD
> from G, L, C
> where
> and G.SELID = L.SELID (+)
> and L.SELID = C.SELID (+)
> and L.SELLEVEL = C.SELLEVEL (+)
>
> How can i write this in Postgres? As the problem is that I use one same
> table for varios joins. This is a problem in Postgres. Any ideas?
>
> When I use the same table in say 3 or 4 joins in one SQL, is the only
> solution unions?? Adn if so, the performance will certainly suffer?
>
I don't quite understand you question. but I presume that G, L,
and C are in fact the same table. I'm not sure what you mean by the (+)
more clarity is really required.
If however G, L, and C are the same table this query can be
rewritten as

select G.SELID, G.TEXT,
L.ID as SELLEVELID , L.SELLEVEL, L.LEVELJOIN, L.LEVELTEXT,
C.ID as KRITERIENFELDID, C.SELFLD
from table as G, table as L, table as C
where
and G.SELID = L.SELID
and L.SELID = C.SELID
and L.SELLEVEL = C.SELLEVEL;

Where table is the name of the table....
I hope that helps

Peter Childs

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

Browse pgsql-sql by date

  From Date Subject
Next Message Christoph Haller 2003-03-24 10:57:08 Re: query 2 database
Previous Message Correia, Carla 2003-03-24 10:49:53 Complex outer joins?