在执行sql:

delete from emp where id in (select id from emp where cdate<'2018-02-02')

时报出以下异常:

### The error occurred while setting parameters
### SQL: delete from emp where id in (select id from emp where cdate<?)
### Cause: java.sql.SQLException: You can't specify target table 'emp' for update in FROM clause
 INFO [main] - Time elapsed:10s.

错误原因:不能先将select出表中的某些值,再update这个表

解决方案:将SQL修改如下:

delete from emp where id in (select id from (select id from emp where cdate<'2018-02-02') as tb)

--END-- 2019年10月14日10:17:27

【SQL】 java.sql.SQLException: You can't specify target table 'emp' for update in FROM clause的更多相关文章

  1. 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 ...

  2. mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM clause

    数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用sql语句来实现.原来以为简单的 update table a set a.字段a=(select b字段 from t ...

  3. 【JDBC】java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

    在使用阿里的druid 时,报了一个异常java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized ...

  4. 【MySQL】java.sql.SQLException: The server time zone value

    错误:Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: The se ...

  5. 【异常】java.sql.SQLException: Could not retrieve transaction read-only status from server Query

    1 详细异常 java.sql.SQLException: Could not retrieve transaction read-only status , ], [ChargingOrderRea ...

  6. 【转】java.sql.SQLException: statement is closed语句被关闭 druid连接池报错

    我之前在用druid 1.0.28版本也出现过这个问题, 现象就是: 报这个错的时候, 往往会出现在一条毫无错误的sql执行上报错,  sql放到数据库上执行或者单独拎出来执行完全没问题, 但是为什么 ...

  7. 【MySQL】java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column

    问题原因: 输入内容包含特殊字符,MySQL 中的列不支持. 解决方法 多数是修改 MySQL 的数据库和表结构,CHARSET 改为 utf8mb4,但本人测试还是不能传入 emoji. 后来在代码 ...

  8. 【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 原因 待更新/删除的数据集与查询的 ...

  9. mysql中【update/Delete】update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update in FROM clause.

    关键词:mysql update,mysql delete update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update ...

随机推荐

  1. Oracle数据库(实例)删除用户和表空间

    删除用户drop user IMPLOCAL cascade; 删除表空间drop tablespace IMPLOCAL including contents and datafiles casca ...

  2. LEANGOO用户设置

    转自:https://www.leangoo.com/leangoo_guide/leangoo_guide_kanban_user.html#toggle-id-7 1. 点击屏幕右上角头像或用户名 ...

  3. PPT 设置幻灯片母版

    现在我设计了一个PPT背景,我想新建幻灯片的时候,直接就是以这个背景展现,并把这个背景作用于左右的幻灯片. 1.选中第二页幻灯片,CTRL + C 复制一下 2.点击视图,幻灯片母版,背景样式,点击下 ...

  4. JAVA语言程序设计课后习题----第六单元解析(仅供参考)

    1 本题就是基本函数的用法 import java.util.Scanner; public class Poone { public static void main(String[] args) ...

  5. C++中volatile

    volatile只保证其“可见性”,不保证其“原子性”. 执行count++;这条语句由3条指令组成: (1)将 count 的值从内存加载到 cpu 的某个 寄存器r: (2)将 寄存器r 的值 + ...

  6. 配置了ssh免密登录,仍然需要输入密码

    1 权限问题         原因 权限问题  chmod -R 700 ~/.ssh 

  7. 前端基础(十):Bootstrap Switch 选择框开关控制

    简介 Bootstrap Switch是一款轻量级插件,可以给选择框设置类似于开关的样式 它是依赖于Bootstrap的一款插件 下载 下载地址 在线引用 导入 因为它是依赖于Bootstrap的一款 ...

  8. linux-2.6.38poll机制简析(以tiny6410按键中断程序为基础)

    一.应用程序 /* struct pollfd { int fd; //文件描述符 short events; //表示请求检测的事件 short revents; //表示检测之后返回的事件 }; ...

  9. mysql—数据库优化——如何选择合适的索引

    索引的分类: 普通索引: 唯一索引: 主键索引:特殊的唯一索引,唯一且不能有null值: 全文索引:全文索引用来对表中的文本域(char, varchar, text)进行索引 全文索引针对myisa ...

  10. 阿里云ACP系列(复习笔记,题库,视频)

    本人通过阿里云ACP认证总结的复习笔记,搜集的视频以及练习题库,助力大家顺利通过阿里云云计算工程师ACP,考试交流可加群:58284982 阿里云认证ACP-ECS (试题占比:31%) 阿里云认证A ...