I have table like this
name | personal_number ----------------------------------------- Jon | 222 Alex | 555 Jon | 222 Jimmy
This should be quicker:
SELECT name FROM mytable join ( SELECT personal_number FROM mytable GROUP BY personal_number HAVING COUNT(*) > 1 )a using (personel_number)
Edit: If this is faster than variant 1, then it means at variant 1 mysql reproduces the inner table for each record again and again.