You can't specify target table 报错的问题
mysql> delete from 表1 where sms_send_uid in (
-> select a.sms_send_uid from 表1 a where a.shop_uid='xxx' and a.send_time between '2017-05-14' and '2017-05-14 23:59:59' and a.status=0
-> and a.sms_send_uid not in ( select max(m.sms_send_uid) from 表1 m where m.shop_uid='xxx' and m.send_time between '2017-05-14' and '2017-05-14 23:59:59' and m.status=0 group by m.mobile )
-> );
ERROR 1093 (HY000): You can't specify target table '表1' for update in FROM clause
修改未如下 就ok
delete from 表1 where sms_send_uid in (
select x.sms_send_uid from (
select a.sms_send_uid from 表1 a where a.shop_uid='xxx' and a.send_time between '2017-05-14' and '2017-05-14 23:59:59' and a.status=0
and a.sms_send_uid not in ( select max(m.sms_send_uid) from 表1 m where m.shop_uid='xxx' and m.send_time between '2017-05-14' and '2017-05-14 23:59:59' and m.status=0 group by m.mobile )
) x
);