1093 - You can't specify target table 'account' for update in FROM clause

 

Objective: To query the same data in a table of two and remove a piece of data.

Check out the first analysis of the same data, and then delete

Query the same data 

SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1;

 

DELETE FROM account WHERE id = (SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1) ;

1093 - You can't specify target table 'account' for update in FROM clause

You can not specify target table 'account' to update the FROM clause.

 

Modified:

DELETE FROM account WHERE id = 

(SELECT t.id from

(SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1) t
);

Guess you like

Origin www.cnblogs.com/hellokitty1/p/11227440.html