I was wondering if there was a way to convert a self subquery to a self join Here is the self subquery
SELECT a,
b
FROM c AS t1
WHERE ( b IN (SELECT b
FROM c AS t2
WHERE ( t1.b = b )
AND ( t1.e <> e )) )
As
e
is the Primary Key another way of approaching this would beIf you only want to find the duplicates an
EXIST
would probably be faster:If you want to join every record with its duplicate but get only one record for each:
(note that i've used
>
instead of<>
)