在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. Spring Boot配置随机数

    Spring Boot支持在系统加载的时候配置随机数. 添加config/random.properties文件,添加以下内容: #随机32位MD5字符串 user.random.secret=${r ...

  2. json传参报错

    restful接口报错: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('e' (code 101)): w ...

  3. java oop第15章_Socket网络编程

    一.   TCP/IP协议(Transmission Control Protocol/Internet Protocol)传输控制协议/Internet协议,是通信领域的基础.核心协议, 其他的协议 ...

  4. 2019-10-10-dotnet-新-sdk-style-项目格式的一些命名空间和引用

    title author date CreateTime categories dotnet 新 sdk style 项目格式的一些命名空间和引用 lindexi 2019-10-10 10:6:46 ...

  5. PHP算法之有效的括号

    给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效. 有效字符串需满足: 左括号必须用相同类型的右括号闭合.左括号必须以正确的顺序闭合.注意空字符串可被认为是 ...

  6. 基于javaweb人脸识别注册登录系统

    ---恢复内容开始--- 现在是2019年,人脸识别技术已经相当成熟了,百度自2017年发布人脸识别技术,已经被广泛应用,不管从现在的iphoneX掀起的面部解锁到手机应用端的各种人脸认证,这一技术已 ...

  7. CSS选择器,层叠

    CSS选择器 .class .intro 选择 class="intro" 的所有元素. 1 #id #firstname 选择 id="firstname" ...

  8. leetcode-158周赛-5223-可以攻击国王的皇后

    题目描述: 自己的提交: class Solution: def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) ...

  9. 一起看下Apache1.3.22版本改进和修正了啥?

    Apache 1.3.20 - 1.3.22主要改进: 安全弱点: 1.在Apache1.3.20的win32平台上发现了一个漏洞.如果客户端发送一个非常长的URI可能导致用目录列表来代替缺省主页.4 ...

  10. Download ubuntu Linux

    https://ubuntu.com/download/desktop