Re: SQL: how to find values NOT in a table
Posted in 1998
Art S. Kagel — — source: Informix-list mailing list archive (1991-1998)
Axel Sander wrote:
> Hi,
> I'm trying to find a solution for the following problem:
> I have 2 tables 'table1' and 'table2' each having the columns 'flag'
> and 'value'. 'flag' could be duplicate and 'value' too, only the
> combination of both is unique. table1 contains all the data, table2
> only a subset. How do I find the rows in table1 which are *not*
> contained in table2? (I'm still using an SE 5.2)
This one is such a common requirement that it should be in the FAQ.
SELECT t1.k1 t1k1, t1.k2 t1k2, ..., t2.k1 t2k1, t2.k2 t2k2, ...
FROM table1 t1, OUTER table2.t2
WHERE t1k1=t2k1 AND t1k2=t2k2 AND ...
INTO TEMP fred;
SELECT t1k1, t1k2, ....
FROM fred
WHERE t2k1 IS NULL;
Art S. Kagel