-- Select Query Before delete query

SELECT *
FROM tblestimate_groups eg
JOIN tblestimates e ON e.id=eg.estimate_id
WHERE e.is_grouping_on = '0';

SELECT *
FROM tblinvoice_groups ig
JOIN tblinvoices i ON i.id=ig.invoice_id
WHERE i.is_grouping_on = '0';

SELECT *
FROM tblchange_order_groups cog
JOIN tblchange_orders co ON co.id=cog.change_order_id
WHERE co.is_grouping_on = '0';

-- Below one is delete query Please backup below table before executing query

DELETE 
FROM 
tblestimate_groups
WHERE estimate_id IN (
SELECT e.id FROM 
tblestimates e
WHERE e.is_grouping_on = '0'
);

DELETE 
FROM 
tblinvoice_groups
WHERE invoice_id IN (
SELECT i.id FROM 
tblinvoices i
WHERE i.is_grouping_on = '0'
);

DELETE 
FROM 
tblchange_order_groups
WHERE change_order_id IN (
SELECT co.id FROM 
tblchange_orders co
WHERE co.is_grouping_on = '0'
);