re: left join

From: Silvio Macedo <smacedo(at)inescn(dot)pt>
To: grim(at)argh(dot)demon(dot)co(dot)uk, pgsql general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: re: left join
Date: 1999-04-26 10:53:52
Message-ID: Pine.LNX.4.04.9904261124480.4165-100000@emperor.inescn.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>Is it just me, or is there no way to do a left join in postgresql?
>Is there any way to do this, I have checked the documentation, looked
>through the src, and there doesnt seem to be a reference to it
>Any comments appreciated

It's not you. :) :(

IMHO, you could do somethink like:

create table t1 ( field_A_of_t1 int, field_Bref_of_t1 int);
create table t2 ( field_Aid_of_t2 int, field_B_of_t2 int);

select field_A_of_t1, field_B_of_t2
from
t1,t2
where
field_A_of_t1 = SOMEVALUE and
field_Aid_of_t2 = field_Bref_of_t1
union
select field_A_of_t1, null
from
t1
where
field_A_of_t1 = SOMEVALUE and field_Bref_of_t1 is null
order by field_B_of_t2;

(I've just checked this - it works.)

Note - using somethink like
... and (field_Aid_of_t2=field_Bref_of_t1 or field_Bref_of_t1 is null)
will not work (you'ld have the product).

I would appreciate if someone verified this suggestion .

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
`````````````````````````````````````````````
Silvio Emanuel Nunes Barbosa de Macedo
mailto:smacedo(at)inescn(dot)pt

INESC - Porto - Grupo CAV
Pc da Republica, 93 R/C Tel:351 2 209 42 21
4000 PORTO PORTUGAL Fax:351 2 208 41 72

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andy Lewis 1999-04-26 12:59:18 Trigger or Rule?
Previous Message Chris Bitmead 1999-04-26 09:47:27 Re: [GENERAL] advice on buying sun hardware to run postgres