在mysql执行下面语句时报错:
 You can’t specify target table for update in FROM clause 

 UPDATE edu_grade_hgm_1
SET exam_natures_new = ''
WHERE
(outid, course_no) IN (
SELECT
a.outid,
a.course_no
FROM
edu_grade_hgm_1 a
INNER JOIN edu_grade b ON a.outid = b.outid
AND a.course_no = b.course_no
)
AND exam_natures_new IS NULL;
 
括号里的子查询和外面的upadate语句均没错,但加在一起便报错了。
那是因为那串英文错误提示就是说,不能先select出同一表中的某些值,
再update这个表(在同一语句中)
 
 
 
 
所以先在子查询外面再套一层,修改sql如下:
 UPDATE edu_grade_hgm_1
SET exam_natures_new = ''
WHERE
(outid, course_no) IN (
SELECT
outid,
course_no
FROM
(
SELECT
a.outid,
a.course_no
FROM
edu_grade_hgm_1 a
INNER JOIN edu_grade b ON a.outid = b.outid
AND a.course_no = b.course_no
) AS temp
)
AND exam_natures_new IS NULL;

mysql出现You can’t specify target table for update in FROM clause的更多相关文章

  1. mysql中You can’t specify target table for update in FROM clause错误解决方法

    mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

  2. 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 c ...

  3. MySQL 出现You can't specify target table for update in FROM clause错误解决方法

    MySQL出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...

  4. MYSQL之You can't specify target table for update in FROM clause解决办法

    mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

  5. mysql error:You can't specify target table for update in FROM clause

    mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

  6. Mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。

    将select出的结果再通过中间表select一遍,这样就规避了错误.注意,这个问题只出现于mysql,mssql和oracle不会出现此问题. mysql中You can't specify tar ...

  7. mysql 出现You can't specify target table for update in FROM clause错误的解决方法

    mysql出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...

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

    使用mysql在删除表中重复记录 delete from user where username in (select user name form(select username from user ...

  9. MySQL中You can't specify target table for update in FROM clause一场

    mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值 ...

随机推荐

  1. 去除字符串中的HTML标签

    背景:Kindeditor内容保存在数据库中的类型是text,包含文字和HTML标签. 需求:显示内容的前50个字(纯文字内容) 方法:将字段查出去除标签,截取前50 import java.util ...

  2. Hadoop 基础知识

    Hadoop 数据是存储在HDFS, Mapreduce 是一种计算框架,负责计算处理. HDFS上的数据存储默认是本地节点数据一份,同一机架不同节点一份,不同机架不同节点一份.默认是存储3份 HDF ...

  3. layui中下拉框问题

    <div class="layui-form-item"> <label class="layui-form-label">上级栏目:& ...

  4. ABP 3.7版本迁移数据库报错未能加载文件或程序集“Castle.Core, Version=4.0.0.0”

    ABP 3.7 3.8版本升级后迁移数据库,报错未能加载文件或程序集“Castle.Core, Version=4.0.0.0”,System.ComponentModel.Annotations也可 ...

  5. mongo之find结果对象map实例处理

    find 找到结果对象列表 res = await SS_StudentsLeaveTask.find(filter=_filter) self.resData = map(lambda x: str ...

  6. touch - 修改文件的时间戳记.

    总览 touch [-acm][-r ref_file(参照文件)|-t time(时间值)] file(文件名)... 被废弃的版本: touch [-acm][ugly_time] file(文件 ...

  7. 2变量与基本类型之const限定符

    一.const介绍: const对象一旦被创建其值就不能再改变,所以const对象必须初始化.任何试图对const赋值的行为都会引发错误. 二.初始化和const: 对const对象的主要限制就是只能 ...

  8. robotframework+python3+selenium之下拉框的选择---第五集

    由于我没有找到option形式的,所以借鉴其他大神的博客内容,如下: 1.F12后看见下拉框的源码是<option xxx> 2.如果F12后看到的下拉源码是这样的: <div xx ...

  9. CentOS 7 編譯qBittorrent Web UI安裝指南

    前言 以下是安装qBittorrent教学. 适用于CentOS7或更新版本 适用于qBittorrent4.1.5或更新版本 安裝須知 qBittorrent基于libtorrent,所以必须先安装 ...

  10. 关于h5打包后 wag包无法安装的问题

    如果不是逻辑错误,那么有可能是下列三种情况之一, 1 wgt打包时的appid与安装包不符 2 打包wgt文件和打包安装包文件 用的不是同一个HBuilder账户 3 安装包打包时权限配置,和wgt包 ...