Select and display only duplicate records in MySQL
The IN
was too slow in my situation (180 secs)
So I used a JOIN
instead (0.3 secs)
SELECT i.id, i.payer_email
FROM paypal_ipn_orders i
INNER JOIN (
SELECT payer_email
FROM paypal_ipn_orders
GROUP BY payer_email
HAVING COUNT( id ) > 1
) j ON i.payer_email=j.payer_email
SELECT id, payer_email
FROM paypal_ipn_orders
WHERE payer_email IN (
SELECT payer_email
FROM paypal_ipn_orders
GROUP BY payer_email
HAVING COUNT(id) > 1
)
sqlfiddle