Answer: No, your request does not make sense.
To indicate whether two entries are โequal,โ you must define the term โequal.โ Should all fields be equal? Or just certain fields?
If you have two tables, TableA and TableB , and they have two fields "A" and "B", then this statement finds all the records that exist in both tables:
select distinct TableA.* from TableA join TableB on TableA.A = TableB.A and TableA.B = TableB.B
or
select * from TableA where exists ( select 1 From TableB where TableA.A = TableB.A and TableA.B = TableB.B )
Edit: User 10e5x indicated that his table contains NULL values. Thus, comparing for each field should be a bit more complicated in order to offset the warnings about NULL comparisons.
I will just put the WHERE part:
where TableA.A = TableB.A or coalesce (TableA.A, TableB.A) is NULL and TableA.B = TableB.B or coalesce (TableA.B, TableB.B) is NULL
The coalesce(a,b,c...) function returns the leftmost value not NULL, therefore
coalesce (A,B) is NULL -- is equal to A is NULL and B is NULL
Note. This complex coding is the reason you should avoid NULL values โโin columns used for comparison.
source share