【SQL】 java.sql.SQLException: You can't specify target table 'emp' for update in FROM clause
在执行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的更多相关文章
- 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 ...
- 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 ...
- 【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 ...
- 【MySQL】java.sql.SQLException: The server time zone value
错误:Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: The se ...
- 【异常】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 ...
- 【转】java.sql.SQLException: statement is closed语句被关闭 druid连接池报错
我之前在用druid 1.0.28版本也出现过这个问题, 现象就是: 报这个错的时候, 往往会出现在一条毫无错误的sql执行上报错, sql放到数据库上执行或者单独拎出来执行完全没问题, 但是为什么 ...
- 【MySQL】java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column
问题原因: 输入内容包含特殊字符,MySQL 中的列不支持. 解决方法 多数是修改 MySQL 的数据库和表结构,CHARSET 改为 utf8mb4,但本人测试还是不能传入 emoji. 后来在代码 ...
- 【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 原因 待更新/删除的数据集与查询的 ...
- 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 ...
随机推荐
- 本地存储和vuex使用对比
1. sessionStorage sessionStorage 方法针对一个 session 进行数据存储.当用户关闭浏览器窗口后,数据会被删除. 用法: 储存: 1. 点(.)运算符 ...
- Activiti使用总结
工作流在我们日常的工作中用得可谓相当普及,尤其在企业内部管理系统,如考勤.财务.合同等系统中更是离不开它.在我们金融科技领域,工作流主要用于贷款审批.风控审核等环节.早期工作流在企业信息化发挥着很重要 ...
- Java秒杀实战 (七)安全优化
转自:https://blog.csdn.net/qq_41305266/article/details/81174782 一.隐藏秒杀地址 思路:秒杀开始前,先去请求接口获取秒杀地址 1.接口改造, ...
- python3学习特性
一 实例变量与类变量 class Pepple: __age=18 __name="zhangfff" @classmethod def GetInfo(cls): print(c ...
- Delphi 类类型和对象
- 008.MVC与数据库的交互
使用ASP.NET MVC实现向数据库插入数据的步骤(程序): (删除,修改,查找)步骤1:创建数据库,创建要使用的表(数据) 表中可以事先插入测试数据步骤2:新建项目,写代码2.1)在配置文件中设置 ...
- linux-2.6.38 input子系统(用输入子系统实现按键操作)
一.设备驱动程序 在上一篇随笔中已经分析,linux输入子系统分为设备驱动层.核心层和事件层.要利用linux内核中自带的输入子系统实现一个某个设备的操作,我们一般只需要完成驱动层的程序即可,核心层和 ...
- UCOSII 之 任务统计
UCOSII 使用空闲任务的计数值(OSIdleCtr)来实现CPU使用率的统计,首先统计一个固定时间内的计数值保存下来为 (MAX),然后再开启一个固定的时间段,当时间到达时得到另外一个(OSIdl ...
- 4'.deploy.prototxt
1: 神经网络中,我们通过最小化神经网络来训练网络,所以在训练时最后一层是损失函数层(LOSS), 在测试时我们通过准确率来评价该网络的优劣,因此最后一层是准确率层(ACCURACY). 但是当我们真 ...
- Appium&Java自动化实现移动端几种典型动作
一.Appium4.0 Pinch&Zoom /* * @FileName Pinch_Zoom: Pinch_Zoom * @author davieyang * @create 2018- ...