If I have some ‘unrelated’ tables (no PK no FK relation between tables), I can check if I have some IDs in one table that are NOT in the other table by:
[pre]
SELECT B.ID
FROM SomeTable B
WHERE (NOT (B.ID IN
(SELECT A.ID FROM OtherTable A)))[/pre]
And that works fine.
Now, if I want to check if there are 2 fields that should match between those 2 tables, I tried:
[pre]
SELECT A.ID || '*' || A.PN
FROM SomeTable A
WHERE (NOT ((A.ID || '*' || A.PN)
IN (SELECT B.ID || '*' || B.PN FROM OtherTable B)))[/pre]
Which is pretty much: concatenate ID and PN (with * between) in both tables and find ‘missing’ records.
That also works, but it takes a long time to process.
Is there any other, better, faster, more elegant way of checking tables by 2 (or more?) fields?
Have fun.
---- Andy
[pre]
SELECT B.ID
FROM SomeTable B
WHERE (NOT (B.ID IN
(SELECT A.ID FROM OtherTable A)))[/pre]
And that works fine.
Now, if I want to check if there are 2 fields that should match between those 2 tables, I tried:
[pre]
SELECT A.ID || '*' || A.PN
FROM SomeTable A
WHERE (NOT ((A.ID || '*' || A.PN)
IN (SELECT B.ID || '*' || B.PN FROM OtherTable B)))[/pre]
Which is pretty much: concatenate ID and PN (with * between) in both tables and find ‘missing’ records.
That also works, but it takes a long time to process.
Is there any other, better, faster, more elegant way of checking tables by 2 (or more?) fields?
Have fun.
---- Andy