In a database table that is linked to another, sometimes an entry gets deleted and the children of that entry don’t get deleted along with it. Use this little bit of SQL to check for these entries:
SELECT one.id
FROM one
WHERE one.other_id NOT IN (
SELECT other.id
FROM other);
This can then be modified to delete those entries by changing the SELECT one.id to DELETE, like this:
DELETE
FROM one
WHERE one.other_id NOT IN (
SELECT other.id
FROM other);


