Tuesday, February 14, 2012

You can't specify target table xxxx for update in FROM clause

wrong:

mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY) and id not in ( (select max(a.id) from  sig_dumps a group by a.profile_id) ) ; ERROR 1093 (HY000): You can't specify target table 'sig_dumps' for update in FROM clause correct: mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY)
and id not in
( select * from
(select max(a.id) from  sig_dumps a group by a.profile_id) t
) ;
Query OK, 0 rows affected (0.02 sec)

No comments:

Post a Comment