From: | Fomichev Michael <fomichev(at)null(dot)ru> |
---|---|
To: | Ant9000 <ant9000(at)seldati(dot)it> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] OUTER JOINs in PostgreSQL |
Date: | 1999-06-14 20:46:49 |
Message-ID: | Pine.LNX.4.04.9906150924340.487-100000@ns.region.utsr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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);
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-06-14 21:20:38 | Re: [SQL] RE: [GENERAL] Two variable passed to PL/Function and on is NULL |
Previous Message | Michael J Davis | 1999-06-14 19:03:48 | RE: [GENERAL] Two variable passed to PL/Function and on is NULL |