在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. 如何删除github里的项目

    1.登录github网站后,就会看到如下画面,在头像下面有个你的项目资源这一栏,假如我要删除名为“hhh”的项目,现在鼠标点进这个项目里面 2.进去后点setting 点进去后,默认是选择了OPtio ...

  2. hdu6325 /// 上凸包

    题目大意: 给定n 为n个点 给定n个点的坐标 两个点(xi,yi) (xj,yj)之间的花费是 xi*yj-yi*xj (可能为负数) 要求从点1经过若干个点到点n最小花费的路径 且路径要按x轴方向 ...

  3. IPC$渗透使用

    简介 IPC$(Internet Process Connection)是共享"命名管道"的资源,它是为了让进程间通信而开放的命名管道,通过提供可信任的用户名和口令,连接双方可以建 ...

  4. 22-5-join

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. WordPress .gitignore

    # ----------------------------------------------------------------- # .gitignore for WordPress @salc ...

  6. h5 app 设置全屏

    h5 app的全屏和沉浸式状态栏是不一样的 全屏模式 常见使用场景:如果页面是全屏游戏,一般会直接让状态栏消失,也就是页面全屏.webview高度全屏了,状态栏没有了.写法: 终端支持:没有终端类型限 ...

  7. jq-demo-日历

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. leetcode-158周赛-5222-分割字符串

    题目描述: 自己的提交: class Solution: def balancedStringSplit(self, s: str) -> int: if not s:return 0 res ...

  9. 2019.7.3模拟 光影交错(穷举+概率dp)

    题目大意: 每一轮有pl的概率得到正面的牌,pd的概率得到负面的牌,1-pl-pd的概率得到无属性牌. 每一轮过后,都有p的概率结束游戏,1-p的概率开始下一轮. 问期望有多少轮后正面的牌数严格大于负 ...

  10. HTML5布局篇

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...