此问题只出现在mysql中 oracle中无此问题

在同一语句中,当你在select某表的数据后,不能update这个表,如:

DELETE FROM tbl_students WHERE id NOT IN (SELECT id FROM tbl_students GROUP BY `name`)

改成下面这样

DELETE FROM tbl_students WHERE id NOT IN (
SELECT t.id FROM
(SELECT id FROM tbl_students GROUP BY `name`)AS t)

将select出的结果再通过中间表select一遍就可以了

You can't specify target table 'tbl_students' for update in FROM clause错误的更多相关文章

  1. 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug

    不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...

  2. mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause

    问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...

  3. mysql的一个特殊问题 you can't specify target table 'cpn_regist' for update in FROM clause

    今天在操作数据库的时候遇到了一个问题,sql语句如下: UPDATE cpn_yogurt_registration SET dep1Name = '1' WHERE `key` in  (SELEC ...

  4. Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause

    Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...

  5. 错误:You can't specify target table 'xxx' for update in FROM clause的解决

    问题: 今天在MySQL数据库删除重复数据的时候遇到了一个问题.如下脚本: DELETE FROM tempA WHERE tid IN ( SELECT MAX(tid) AS tid FROM t ...

  6. [Err] 1093 - You can't specify target table 's' for update in FROM clause

    [Err] 1093 - You can't specify target table 's' for update in FROM clause 执行SQL DELETE from book WHE ...

  7. 【MySQL】解决You can't specify target table 'user_cut_record_0413' for update in FROM clause

    问题 You can't specify target table 'user_cut_record_0413' for update in FROM clause 原因 待更新/删除的数据集与查询的 ...

  8. You can't specify target table 'ship_product_cat' for update in FROM clause

    有时候我们在编辑update时需要select作为条件,在mysql中有时会出现这样的错误:You can't specify target table for update in FROM clau ...

  9. MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause

    MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...

随机推荐

  1. C++ Lambda表达式基本用法(言简意赅,非常清楚)

    创建一个匿名函数并执行.Objective-C采用的是上尖号^,而C++ 11采用的是配对的方括号[].实例如下: 1 2 3 4 5 6 7 8 9 #include <iostream> ...

  2. CodeForces Round#229 DIV2 C 递归DP

    这条路是只说哦话题,没有注意到k只有最大射程10,所以昨天晚上,一个很长的纠结.没有好的办法来处理,后来不情愿地去寻找解决问题的办法,研究发现,人们对开始到句子,由于k的范围比较小 所以....... ...

  3. 解析Android的 消息传递机制Handler

    1. 什么是Handler: Handler 网络释义"机械手.经理"意思,在Android它用于管理多个线程UI操作: 2. 为什么会出现Handler: 在Android里面的 ...

  4. [Erlang危机](4.4)命名管道

    原创文章,转载请注明出处:server非业余研究http://blog.csdn.net/erlib 作者Sunface . .To connect to the node, you use the ...

  5. 搜索服务器Elasticsearch

    基本 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为Ap ...

  6. WPF 附加属性的使用

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  7. jquery动态创建小广告

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  8. MVC 异步调用

    @{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport&q ...

  9. byte[] 左移和右移

    public static class ex { public static byte[] RightShift(this byte[] ba, int n) { ) { return ba.Left ...

  10. Window 下 MySQL 环境的安装

    Window 下 MySQL 环境的安装 简介: MySQL 是最流行的关系型数据库管理系统,在WEB应用方面 MySQL 是最好的RDBMS(Relational Database Manageme ...