pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAntw: LEFT JOIN
4+ messages / 4 participants
[nested] [flat]
* Antw: LEFT JOIN
@ 2000-07-04 12:46 Gerhard Dieringer <DieringG@eba-haus.de>
2000-07-04 13:34 ` Re: Antw: LEFT JOIN Antti Linno <alligator@all.ee>
0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Dieringer @ 2000-07-04 12:46 UTC (permalink / raw)
To: " <Antti Linno" <alligator@all.ee>; +Cc: pgsql-sql
Antti Linno wrote:
> Greetings.
> I have a problem. I have 2 tables. E.g. work and workers. I want to
> select records, that 1st table has, and the second hasn't(both have id
> attribute). I mean I can't do it with is NULL, because those records don't
> exist. I was shown, how it is done with mysql
I think, the following select will solve your problem
select first.id
from first
except
second.id_first
from second;
>
> select first.id,second.id_first
> from first left join second on
> id=id_first where id_first is NULL;
>
This query should never give any result, because you require
id_first = id and id_first is null
but if id_first is null then it's equal to nothing,
and BTW it's also unequal to nothing.
> but when I tried it in psql, it said, not implemented.
Outer joins (left or right joins) are not implemented in PostgreSQL 7.0, but will
come in 7.1.
>
> Antti
Gerhard
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Antw: LEFT JOIN
2000-07-04 12:46 Antw: LEFT JOIN Gerhard Dieringer <DieringG@eba-haus.de>
@ 2000-07-04 13:34 ` Antti Linno <alligator@all.ee>
2000-07-04 14:54 ` Re: Antw: LEFT JOIN Erol Oz <eroloz@bilgi.edu.tr>
2000-07-04 19:43 ` Re: Antw: LEFT JOIN Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 4+ messages in thread
From: Antti Linno @ 2000-07-04 13:34 UTC (permalink / raw)
To: pgsql-sql
> I think, the following select will solve your problem
>
> select first.id
> from first
> except
> second.id_first
> from second;
>
Nay, I got parse error.
Antti
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Antw: LEFT JOIN
2000-07-04 12:46 Antw: LEFT JOIN Gerhard Dieringer <DieringG@eba-haus.de>
2000-07-04 13:34 ` Re: Antw: LEFT JOIN Antti Linno <alligator@all.ee>
@ 2000-07-04 14:54 ` Erol Oz <eroloz@bilgi.edu.tr>
1 sibling, 0 replies; 4+ messages in thread
From: Erol Oz @ 2000-07-04 14:54 UTC (permalink / raw)
To: Antti Linno <alligator@all.ee>; +Cc: pgsql-sql
Antti Linno wrote:
>
> > I think, the following select will solve your problem
> >
> > select first.id
> > from first
> > except
> > second.id_first
> > from second;
> >
> Nay, I got parse error.
'select' is missing after 'except'.
select first.id
from first
except
select second.id_first
from second;
erol
> Antti
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Antw: LEFT JOIN
2000-07-04 12:46 Antw: LEFT JOIN Gerhard Dieringer <DieringG@eba-haus.de>
2000-07-04 13:34 ` Re: Antw: LEFT JOIN Antti Linno <alligator@all.ee>
@ 2000-07-04 19:43 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lane @ 2000-07-04 19:43 UTC (permalink / raw)
To: Antti Linno <alligator@all.ee>; +Cc: pgsql-sql
Antti Linno <alligator@all.ee> writes:
>> I think, the following select will solve your problem
>>
>> select first.id
>> from first
>> except
>> second.id_first
>> from second;
>>
> Nay, I got parse error.
Should be ... EXCEPT SELECT second.id_first ...
Anyway, we should have full ANSI join support in 7.2, or 7.1 if
we get lucky.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-07-04 19:43 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-07-04 12:46 Antw: LEFT JOIN Gerhard Dieringer <DieringG@eba-haus.de>
2000-07-04 13:34 ` Antti Linno <alligator@all.ee>
2000-07-04 14:54 ` Erol Oz <eroloz@bilgi.edu.tr>
2000-07-04 19:43 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox