DELETE FROM stat_globaluid WHERE id NOT IN ( SELECT id FROM ( SELECT id FROM stat_globaluid ORDER BY id DESC LIMIT 100 ) foo );