sql >> Base de Datos >  >> RDS >> Mysql

¿Cómo eliminar todos los registros huérfanos en MySQL?

Podrías usar not exists :

delete from user
where not exists (select * from message m where m.userid = user.id)
      and not exists (select * from archivedMessage am where am.userid = user.id)