MySQL can’t specify target table for update in FROM clause
2016-10-12 17:19
351 查看
翻译:MySQL不能指定更新的目标表在FROM子句
源SQL语句:
[sql] view plain copy
print?
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)
执行报以下错误:
[sql] view plain copy
print?
[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 in FROM clause
解决代码如下:
[sql] view plain copy
print?
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
);
分析:
先把要删除的目标放到一张临时表再把要删除的条件指定到这张临时表即可。
http://blog.csdn.net/bluestarf/article/details/46622455 http://www.cnblogs.com/nick-huang/p/4412818.html
源SQL语句:
[sql] view plain copy
print?
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)
执行报以下错误:
[sql] view plain copy
print?
[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 in FROM clause
解决代码如下:
[sql] view plain copy
print?
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
);
分析:
先把要删除的目标放到一张临时表再把要删除的条件指定到这张临时表即可。
http://blog.csdn.net/bluestarf/article/details/46622455 http://www.cnblogs.com/nick-huang/p/4412818.html
相关文章推荐
- MYSQL之You can't specify target table for update in FROM clause解决办法
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- mysql中You can't specify target table for update in FROM clause错误 转
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- Mysql 错误 Code: 1093. You can't specify target table for update in FROM clause
- MySQL:You can’t specify target table ‘A’ for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- MySQL:You can’t specify target table ‘A’ for update in FROM clause
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- MySQL can’t specify target table for update in FROM clause
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- mysql中错误:1093-You can’t specify target table for update in FROM clause的解决方法
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- mysql中You can't specify target table for update in FROM clause错误
- mysql 出现You can't specify target table for update in FROM clause错误的解决方法
- MySQL报错“ you can't specify the target table for ‘update’ in from clause”
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- MySQL can’t specify target table for update in FROM clause
- MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause