create table people (person_id integer not null primary key, surname varchar(40) not null)
insert into people values (1,'Smith')
insert into people values (2,'Jones')
insert into people values (3,'Harry')
insert into people values (4,'Peanut')
create table town (person_id integer not null references people(person_id), town varchar(40) null)
insert into town values (1,'Bristol')
insert into town values (2,'Washington')
insert into town values (3,NULL)
insert into town values (4,'Cairns')
SELECT surname, town
FROM people, town
WHERE people.person_id *= town.person_id
AND (town <> 'Washington' AND town IS NOT NULL)
####
surname town
------------------------------ ----------------------------------------
Smith Bristol
Jones NULL
Harry NULL
Peanut Cairns
##
##
SELECT surname, town
FROM people
LEFT OUTER JOIN town
ON people.person_id = town.person_id
WHERE (town <> 'Washington' AND town IS NOT NULL)
##
##
surname town
---------------------------------------- ----------------------------------------
Smith Bristol
Peanut Cairns