Remove bad 'child' records to enable or create a foreign key
                                                 Last update (2008-05-18 13:04:41)
                                                                                                                   Date added (2008-05-18 12:56:07)

Summary
If you get "Parent Keys Not Found" error when you try to enable/create relation from a child table to parent table, then you must identify and remove bad 'child' records.

The records can be identified and removed using the query:
        DELETE FROM childtablename ct
        WHERE NOT EXISTS (SELECT 'x' FROM parenttablename pt 
        WHERE ct.keycolumn1 = pt.keycolumn1 AND ct.keycolumn2 = pt.keycolumn2...);
Reviews
Filters
Search