DELETE FROM pp_redirects WHERE id IN (SELECT id FROM (SELECT r1.id FROM pp_redirects r1 INNER JOIN pp_redirects r2 ON r1.`from` = r2.`from` AND (r1.lang_id <=> r2.lang_id) AND (IFNULL(r1.date_add, '1000-01-01 00:00:00') < IFNULL(r2.date_add, '1000-01-01 00:00:00') OR (IFNULL(r1.date_add, '1000-01-01 00:00:00') = IFNULL(r2.date_add, '1000-01-01 00:00:00') AND r1.id < r2.id))) AS tmp);