Skip to content

Instantly share code, notes, and snippets.

@midnite81
Created October 17, 2016 09:29
Show Gist options
  • Save midnite81/ea867d9d91f81827088abeffc30d4552 to your computer and use it in GitHub Desktop.
Save midnite81/ea867d9d91f81827088abeffc30d4552 to your computer and use it in GitHub Desktop.
Remove Duplicate Rows, Keeping the first lin
DELETE FROM my_table
USING my_table, my_table mt1
WHERE my_table.id > mt1.id
AND my_table.my_column = mt1.my_column -- the column which you're checking for duplicates on
AND my_table.`type` = 'greeting'; -- any other conditions that you need to filter by
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment