Translation: MySQL cannot specify the updated target table in the FROM clause
SOURCE SQL statement:
[SQL]View PlainCopyprint?
- Delete from t_official_sys_user
- where user_name in (SELECT user_name from t_official_sys_user b Group by b. ' User_name ' Having count (1) > 1)
The following error was reported:
[SQL]View PlainCopyprint?
- [SQL]
- Delete from t_official_sys_user
- where user_name in (SELECT user_name from t_official_sys_user b Group by B. ' user_name ' having COUNT (1) > 1)
- [ERR] 1093-you can' t specify target table ' T_official_sys_user ' for update on from clause
The resolution code is as follows:
[SQL]View PlainCopyprint?
- Delete from t_official_sys_user
- where user_name in (
- Select User_name from
- (
- SELECT user_name from t_official_sys_user b Group by B. ' user_name ' having count (1) > 1
- ) as temtable
- );
Analysis:
First, put the target to be deleted to a temporary table and then assign the conditions to be removed to this temporary table.
http://blog.csdn.net/bluestarf/article/details/46622455
Http://www.cnblogs.com/nick-huang/p/4412818.html
MySQL can ' t specify target table for update on FROM clause