mysql5.7以前的操作是,可以正常删除数据
DELETE FROM table1 WHERE id IN ( SELECT * FROM ( SELECT id FROM table1 WHERE id < 30 ) a )
mysql5.7的操作需要微调一下,因为mysql5.7的sql优化后又会触发异常,解决方案为:子句增加一个DISTINCT
DELETE FROM table1 WHERE id IN ( SELECT * FROM ( SELECT DISTINCT id FROM table1 WHERE id < 30 ) a )