Here’s a MySQL scriptlet you won’t want to forget: “select child.id from child left join parent on (child.parent_id=parent.id) where child.id is not null and parent.id is null;” According to Dennis Haney, the original poster of this scriptlet (as found in his comment on this MySQL dev page here) you will get the error “ERROR 1216: [...]