-
I am trying to compare 2 tables, to check if the same transaction number is used in either table.
I have tried
select * from table1 a
where exists (select 1 from table2 b
where a.trans=b.trans)
but how can I specify a query to do the check on both tables at the same time?
-
Is transaction_number unique ? Why don't you just join the tables:
select * from table1 a, table2 b
where b.trans = a.trans
This will only give you rows which are common to both tables.
-
Scorby,
You could try this extension to your code....
select * from table1 a
where exists (select 1 from table2 b
where a.trans=b.trans union select 2 from table3 c
where c.trans=a.trans )
!
ssmith, your code would probably return a "true" iif the 'join' evaluates to a true on both the tables(b & c) and may not go with Scorby's "either" clause..
Mahesh.