此问题只出现在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. WPF 判断调用方法堆栈

    原文:WPF 判断调用方法堆栈 版权声明:博客已迁移到 http://lindexi.gitee.io 欢迎访问.如果当前博客图片看不到,请到 http://lindexi.gitee.io 访问博客 ...

  2. Data analysis system

    A data analysis system, particularly, a system capable of efficiently analyzing big data is provided ...

  3. UWP 扩展/自定义标题栏的方法,一些概念和一些注意事项

    原文 UWP 扩展/自定义标题栏的方法,一些概念和一些注意事项 在 Windows 10 的前几个版本中将页面内容扩展到标题栏上还算简单,主要是没什么坑.直到一些新控件的引入和一些外观设计趋势变化之后 ...

  4. Windows10的Ubuntu子系统开启桌面环境

    原文:Windows10的Ubuntu子系统开启桌面环境 Ubuntu 优势之一就是桌面环境比较好,所以咱们的子系统当然也不能少了这一环节,本小结开始安装Ubuntu 桌面系统. 安装环境 使用下面指 ...

  5. 微信4.5 for Android安卓内测版体验【实时对讲】杀手级应用下载

    微信4.5 for Android 安卓 内测版 体验 程序启动画面,是一支在动的烛光 主要功能更新如下 支持语音提醒,到时间后自动弹出消息框 发起语音提醒请求 成功识别语音请求,并且保存在本地,应该 ...

  6. 使用devcpp在windowXP上qt4.4.3安装与使用入门

    1.安装前先安装devcpp,我下载的是devcpp-4.9.9.2_setup.exe2.安装qt4.4.3,下载的是qt-win-opensource-4.4.3-mingw.rar,解压后运行后 ...

  7. TASM 5.0 安装及使用教程

    安装TASM 5.0很简单,您只需要下载本站[相关工具]中的"TASM50.zip"文件,解压后在Windows9x/NT下执行"INSTALL.EXE"即可开 ...

  8. SVN如何迁徙到Git

    由于一直都是采用SVN作为源码管理,转到Git不能从头开始吧~~下面就具体说说如何将SVN已有的项目工程迁徙到Git上面 步骤 (1) 安装Git客户端程序(2) 将SVN上面的工程通过Git克隆到本 ...

  9. JSTL自定义标签 实现forEach循环支持集合.数组

    java代码实现 tld配置 JSP页面代码

  10. WPF 数据模板的使用

    <Window x:Class="CollectionBinding.MainWindow"        xmlns="http://schemas.micros ...