Re: SQL: how to find values NOT in a table
Posted in 1998
Or
select * from tab1
where col1||col2 not in (
select col1||col2 from tab2)
Or
Select * from tab1 where not exists (
select * from tab2 where tab1.col1=tab2.col1
and tab1.col2=tab2.col2)
Art S. Kagel wrote in message <36701750.1289@bloomberg.net>...
>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