delete FROM `customer` where !(noventa or ( id in (select idcustomer from invoice) or id in (select idcustomer from accountcus) or id in (select idcustomer from anticipos)))