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. 设计通用的Adapter

    2019年3月18日 10:53:27 参照博文:Android 快速开发系列 打造万能的ListView GridView 适配器 一 BaseViewHolder public class Bas ...

  2. docker部署jira破解版

    1.制作Dockerfile FROM cptactionhank/atlassian-jira-software:7.12.0 USER root # 将代理破解包加入容器 COPY "a ...

  3. FreeRTOS 启动进程调度后,程序卡死的部分原因分析。

    现象:1,RTOS  使用时 系统卡启动文件               B       .处. 原因分析:该种情况是由于定义开启了中断,但是未开启中断处理服务.程序执行到中断响应式无对应的程序响应 ...

  4. shell脚本之不同系统上ftp交互使用

    场景:当公司将有文件要自动将ubuntu系统的文件要上传到windows上面,或者windows上的文件要下载到ubuntu上面,尤其是像什么日志啊,编译结果啊,测试结果啊等等,做个备份或者做分析处理 ...

  5. C程序设计实验报告

    试验项目:1.字符与ASCLL码 2.运算符与表达式的运用 3.顺序结构应用程序 4.数学函数的算法描述 5.鸡兔同笼的算法描述 6.确定坐标的算法描述 姓名:郭薪   实验地点:514实验室   试 ...

  6. php 数组写入文件

    $fiele = '../data/conf/watermark.php';//指定要写入的文件 $param = $this->request->param(); $watermark ...

  7. Core 2.0使用Nlog记录日志+Mysql

    一.先创建一个Core2.0的项目,并在NuGet中引入3个类库文件 MySql.Data.dll NLog.dll NLog.Web.AspNetCore.dll 二.创建一个nlog.config ...

  8. XMLHttpRequest中常用的方法

    a.) abort() 停止当前请求b.) getAllResponseHeaders() 把HTTP请求的所有响应首部作为键值对返回c.) open("method", &quo ...

  9. javascript 总结(常用工具类的封装)

    1. type 类型判断 isString (o) { //是否字符串 return Object.prototype.toString.call(o).slice(8, -1) === 'Strin ...

  10. Nuxt.js国际化vue-i18n的搭配使用

    Nuxt.js国际化的前提是,已经使用脚手架工具搭建好了Nuxt.js的开发环境. 我使用的环境是nuxt@2.3 + vuetify@1.4 + vue-i18n@7.3 1. 先安装vue-i18 ...