Last active
August 29, 2015 14:06
-
-
Save jwliechty/7545881b0201ed55324f to your computer and use it in GitHub Desktop.
Delete all unused foreign keys in 'child' that are supposed to be referenced from 'parent'. (Rows in child belong to rows in parent where child.id = parent.child_id).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM child WHERE id IN | |
( | |
SELECT child.id FROM child LEFT JOIN parent ON child.id=parent.child_id WHERE parent.child_id IS NULL | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment