You can't specify target table 'sc' for update in FROM clause

背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;

上面的sql是我写的,执行就报这个错,这个原因说的是 不能从自己表里查数据再更新自己

解决方法:嵌套一层中间表

update sc set sc.score =
(select t1.score from (select avg(sc1.score) score from sc sc1 where sc1.c_id=(select course.c_id from teacher,course where course.t_id=teacher.t_id and tname='叶平')) t1)
where sc.c_id = (select course.c_id from teacher,course where course.t_id=teacher.t_id and tname='叶平');

这种问题仅存在于mysql中,在Oracle中是不存在的,因此在此打个mark 以防下次又忘记了

mysql uodate 报错 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在删除表中重复记录 delete from user where username in (select user name form(select username from user ...

  2. mysql错误:1093-You can’t specify target table for update in FROM clause的解决方法

    update语句中包含的子查询的表和update的表为同一张表时,报错:1093-You can’t specify target table for update in FROM clause my ...

  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 UPDATE edu_grade_hgm_1 ' W ...

  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中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

    mysql 一个较特殊的问题:You can't specify target table for update in FROM clause 即:不能先select出同一表中的某些值,再update ...

  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错误解决方法,需要的朋友可以参考下 MySQL中You c ...

  8. 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同一个表的某些值 ...

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

    You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 出现以上错误,是因为想将表自身的字 ...

随机推荐

  1. python使用pip 18以上版本离线安装package

    在内网办公环境,常常需要使用离线安装python的软件包. 一般都会先在互联网的电脑上下载,再拷贝到内网办公机器上进行离线安装. 一般来说,我是这样做的: 1.拷贝和外网电脑上版本一致,且32位或64 ...

  2. 【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user

    运行Flask时出现了一个错误, AssertionError: View function mapping is overwriting an existing endpoint function: ...

  3. 使用gethostname()函数和gethostbyname()函数获取主机相关信息

    gethostname() : 返回本地主机的标准主机名. 原型如下: #include <unistd.h> int gethostname(char *name, size_t len ...

  4. Typescript---03 类、接口、枚举

    传统的javascript程序使用函数和基于原型的继承来创建可重用的组件,从ECMAScript2015(ECMAScript 6)开始,可以使用基于类的面向对象方式. 一.类: 定义类(class) ...

  5. .net基础学java系列(五)慢性自杀 之 沉沦在IDE中

    最近在慢学习IDEA,总是喜欢与Visual Studio! 其实,对于Visual Studio,它的官方(https://docs.microsoft.com/zh-cn/visualstudio ...

  6. 关于定时脚本crontab的坑

    需求: 每分钟执行一次程序,将处理后的数据写入mongodb 最初做法: 1):写crontab没有响应,于是打算通过shell脚本的while true来执行 当时sb,没控制时间内,而且我还是用n ...

  7. spark DataFrame 读写和保存数据

    一.读写Parquet(DataFrame) Spark SQL可以支持Parquet.JSON.Hive等数据源,并且可以通过JDBC连接外部数据源.前面的介绍中,我们已经涉及到了JSON.文本格式 ...

  8. fastdfsDemo

    package com.xpl.fastdfs; import org.csource.common.NameValuePair;import org.csource.fastdfs.*;import ...

  9. Gatsby上手指南 - 让你的静态网站用react来高逼格的写

    注意:Gatsby V2版本安装及使用问题请移步<Gastby V2安装过程中常见问题>,此文较旧,主要针对V1版Gatsby而介绍 前言 一直以来都是用之前比较流行的静态网站生成器Hex ...

  10. 《Spark大数据处理》---Spark原理