PrepZone Logo
PrepZone
Back to Database

Database · Medium

Delete orphan records not referenced by any parent.

DatabaseSQL QueriesSenior

Answer preview

Orphans are found with an anti-join — child rows whose foreign key value has no matching parent — and deleted with the same predicate in a DELETE.…