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. 微软推荐的.net命名规范

    许多命名约定都与标识符的大小写有关.值得注意的是,公共语言运行库 (CLR) 支持区分大小写和不区分大小写的语言.本主题中描述的大小写约定可帮助开发人员理解和使用库. 大小写样式 下列术语描述了标识符 ...

  2. Centos安装Git、DotNet、Docker

    1.安装Git yum install git 可通过下面的命令查看Git版本 git --version 2.安装Dotnet sudo yum install libunwind libicu 导 ...

  3. 【转】Python——读取html的table内容

    Python——python读取html实战,作业7(python programming) 查看源码,观察html结构 # -*- coding: utf-8 -*- from lxml.html ...

  4. 【转】iPython入门技巧

    [转]http://www.cnblogs.com/cuiyubo/p/6823478.html 学习<利用python进行数据分析> 第三章 IPython:一种交互式计算和开发环境的笔 ...

  5. P2444 [POI2000]病毒

    P2444 [POI2000]病毒 题目描述 二进制病毒审查委员会最近发现了如下的规律:某些确定的二进制串是病毒的代码.如果某段代码中不存在任何一段病毒代码,那么我们就称这段代码是安全的.现在委员会已 ...

  6. 怎么在PDF上进行文字修改

    文件相信大家不论是工作中还是在学习生活中都会有遇到,有时候我们会遇到PDF文件中的文字有时候会有错误的时候,这个时候就需要对修改PDF文件上的文字,那么具体要怎么做呢,PDF文件需要借助软件才可以编辑 ...

  7. Python判断输入字符类型

    """从键盘上输入 一个字符,判断其字符类型.""" while True: char = input("请输入需要判断的字符:& ...

  8. A页面跳转到B页面后打开指定tabs标签

    A页面: <!DOCTYPE html><html lang="en" class="no-js">    <head>   ...

  9. 【转载】如何直观的理解 O(logn) 时间复杂度的神奇之处

    转自 https://blog.csdn.net/u012814856/article/details/83010082 一.引言最近在极客时间上订阅了<数据结构与算法>的课程,其中王争老 ...

  10. sqlserver 删除表结构

    sqlserver-----------删除表结构use IndividualTaxGOdeclare @sql varchar(8000)while (select count(*) from sy ...