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:
Delete fromTblwhereIdinch ( Select Max(ID) fromTBL Awhere EXISTS ( Select 1 fromTBL BwhereA.tac=B.tacGroup byTac having Count(1)>1 ) Group byTAC)
Rewrite it to the following line:
Delete fromTblwhereIdinch ( Selecta.ID from ( Select Max(ID) ID fromTBL Awhere EXISTS ( Select 1 fromTBL BwhereA.tac=B.tacGroup byTac having Count(1)>1 ) Group byTAC) a)
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.
Http://www.jb51.net/article/60926.htm
MySQL in your can ' t specify target table for update on FROM clause error resolution