Skip to content

Instantly share code, notes, and snippets.

@GeeH
Forked from Ocramius/query.sql
Created February 21, 2013 11:13
Show Gist options
  • Save GeeH/5004002 to your computer and use it in GitHub Desktop.
Save GeeH/5004002 to your computer and use it in GitHub Desktop.
DELETE FROM
blah
WHERE
id NOT IN (
SELECT
c.id
FROM
blah c
LEFT JOIN
blah d
ON (
c.common_field = d.common_field
AND c.id < d.id
)
WHERE
d.id IS NULL
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment