delete from comments inner join status S on (comments.cabecera_cliente=S.cabecera_cliente) where s.id_status=4 delete from status where id_status=4