-- Collect ids
CREATE TEMPORARY TABLE cleanup_lookup AS
SELECT id FROM table1 WHERE condition;
-- Delete the selected records
DELETE t FROM table1 t INNER JOIN cleanup_lookup l ON t.id = l.id;
-- Temporary tables get dropped when the connection is closed.