Commit | Line | Data |
---|---|---|
1 | ALTER TABLE contacts DROP FOREIGN KEY contacts_ibfk_2; | |
2 | DELETE FROM contacts | |
3 | WHERE NOT EXISTS (SELECT profiles.* | |
4 | FROM profiles | |
5 | WHERE profiles.pid = contacts.contact); | |
6 | ALTER TABLE contacts ADD FOREIGN KEY (contact) REFERENCES profiles (pid) ON DELETE CASCADE ON UPDATE CASCADE; | |
7 | ||
8 | -- vim:set syntax=mysql: |