I need to export all the records with a duplicate value in a field to a different table. Namely all records where code appears more than once must be copied.
This is the query I tried:
INSERT INTO alternatives
SELECT * FROM winter WHERE code IN
(SELECT code
FROM winter
GROUP BY code
HAVING COUNT(*) > 1)
but nothing happens, the mysql client hangs indefinitely until I stop it, and no records appear in the alternatives table. What am I doing wrong?
Alternatively, is there a better way to do what I need?
alternativesandwinterhas different table structure. wait, you said it's work withoutINcondition?