MySQL in your can ' t specify target table for update in FROM clause error means that you cannot select some of the values in the same table first, and then update the table (in the same statement). For example, the following SQL:
12(3 select max (ID) from TBL A where EXISTS4 (5 Select 1 from tbl B where A.tac=b.tac GROUP by TAC has count (1) >16 )
7 Group by TAC8 )
Rewrite it to the following line:
Delete from the TBL where ID in (the select a.ID from (the select MAX (ID) ID from the TBL a where EXISTS ( 1 from TBL B where A.tac=b.tac GROUP by TAC have count (1) >1 ) Group by TAC )
In other words, the result of select is passed through the intermediate table select again, thus avoiding the error. Note that this issue only occurs in Mysql,mssql and Oracle does not occur.
Quote from:! [Script House] (http://www.jb51.net/article/60926.htm)
MySQL in your can ' t specify target table for update on FROM clause error resolution