Skip to content

Instantly share code, notes, and snippets.

@alvarezr
Last active December 17, 2015 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alvarezr/5540771 to your computer and use it in GitHub Desktop.
Save alvarezr/5540771 to your computer and use it in GitHub Desktop.
Example of how to delete duplicate entry
-- DELETE duplicate entry
BEGIN;
CREATE
TABLE tempT SELECT MIN(id) id
FROM L_table
GROUP BY l_field, etc ASC;
DELETE
FROM L_table
WHERE id NOT IN (SELECT id
FROM tempT);
DROP TABLE tempT;
COMMIT
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment