This is somewhat related to this question:
I have a table with a primary key, and I have several tables that reference that primary key (using foreign keys). I need to
DELETE FROM group g WHERE NOT EXISTS ( SELECT NULL FROM table1 t1 WHERE t1.groupid = g.groupid UNION ALL SELECT NULL FROM table1 t2 WHERE t2.groupid = g.groupid UNION ALL … )