problems with left outer join - Mailing list pgsql-novice

From Andreas Andreakis
Subject problems with left outer join
Date
Msg-id 85e6ec170610050113p7ebe436ej618481100b848a5e@mail.gmail.com
Whole thread Raw
Responses Re: problems with left outer join  (Andy Chambers <andychambers2002@yahoo.co.uk>)
Re: problems with left outer join  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Hi,

I would like to make a left outer join between two tables (A and B) and then only select rows of table A which do not apply on the join condition (where B is null)

simple example:

create table A(
 id int primary key
);

create table B(
 id int primary key
);

insert into A values(1);
insert into A values(2);
insert into B values(1);

The goal is now to make a join between A and B and to select only the row from A with the id = 2 (because there is no corresponding id in Table B)

So I tried:

select *
from A t1 left outer join B t2 on t1.id = t2.id
where t2.id = null

but I dont get any row returned. I expect the result: 2 | NULL


if I execute

select *
from A t1 left outer join B t2 on t1.id = t2.id

I get:
1) 2 | NULL
2) 1 | 1

what am I doing wrong ?
thanx in advance,
Andreas

pgsql-novice by date:

Previous
From: Stuart Bishop
Date:
Subject: Re: Conditional INSERT: if not exists
Next
From: Ray Stell
Date:
Subject: Re: postgresql db account