Subject | Re: [ib-support] Re: COUNT discrepancy in DSQL & VIEW |
---|---|
Author | lele@seldati.it |
Post date | 2002-05-17T09:50:13Z |
>>>>> On Fri, 17 May 2002 09:39:43 -0000, "csswa" <csswa@...> said:c> What would be the quickest SQL to compare two tables to find
c> records that only appear in one or the other?
SELECT 'AONLY', *
FROM table_a
WHERE NOT EXISTS (SELECT *
FROM table_b
WHERE table_a.KEY = table_b.KEY)
UNION
SELECT 'BONLY', *
FROM table_b
WHERE NOT EXISTS (SELECT *
FROM table_a
WHERE table_a.KEY = table_b.KEY)
This assuming table_a has the same definition as table_b.
Given that in your case there is just more records in one of the
tables than in the other, you may simplify the above removing the
right chunk of the union.
hth,
bye, lele
--
nickname: Lele Gaifax | Quando vivro' di quello che ho pensato ieri
real: Emanuele Gaifas | comincero' ad aver paura di chi mi copia.
email: lele@... | -- Fortunato Depero, 1929.