Re: [SQL] OUTER JOINs in PostgreSQL - Mailing list pgsql-sql

From Fomichev Michael
Subject Re: [SQL] OUTER JOINs in PostgreSQL
Date
Msg-id Pine.LNX.4.04.9906150924340.487-100000@ns.region.utsr
Whole thread Raw
In response to Re: [SQL] OUTER JOINs in PostgreSQL  (Ant9000 <ant9000@seldati.it>)
List pgsql-sql
On Sat, 5 Jun 1999, Ant9000 wrote:

> On Wed, 02 Jun 1999, you wrote:
> >I think that you are looking for something like:
> >
> >SELECT m.id, m.name, d.lastvisit, d.info
> >       FROM master m, detail d
> >       WHERE m.id = d.id;
> >
> >Jason
> >
> 
> No, that way I get an inner join: in my example the result would be
> 
> id | name  | lastvisit | info
> -----------------------------
> 1  | Alpha | Wed Jun 02 19:43:08 1999 CEST | blah blah
> 1  | Alpha | Wed Jun 02 19:45:08 1999 CEST | some more blah's
> 
> and I'm instead looking for this output:
> 
> id | name    | lastvisit | info
>  -----------------------------
> 1  | Alpha   | Wed Jun 02 19:43:08 1999 CEST | blah blah
> 1  | Alpha   | Wed Jun 02 19:45:08 1999 CEST | some more blah's
> 2  | Beta     |                                                 |
> 3  | Gamma |                                                 |
> 
Try this:

SELECT m.id, m.name, d.lastvisit, d.info      FROM master m, detail d      WHERE m.id = d.id
UNION ALL
SELECT m.id, m.name, 0, 0      FROM master m      WHERE not m.id=ANY(select id from detail);



pgsql-sql by date:

Previous
From: Michael J Davis
Date:
Subject: RE: [GENERAL] Two variable passed to PL/Function and on is NULL
Next
From: Tom Lane
Date:
Subject: Re: [SQL] RE: [GENERAL] Two variable passed to PL/Function and on is NULL