re: left join - Mailing list pgsql-general

From Silvio Macedo
Subject re: left join
Date
Msg-id Pine.LNX.4.04.9904261124480.4165-100000@emperor.inescn.pt
Whole thread Raw
In response to left join  (M Simms <grim@argh.demon.co.uk>)
Responses Trigger or Rule?  (Andy Lewis <alewis@themecca.net>)
List 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@inescn.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









pgsql-general by date:

Previous
From: Chris Bitmead
Date:
Subject: Re: [GENERAL] advice on buying sun hardware to run postgres
Next
From: Andy Lewis
Date:
Subject: Trigger or Rule?