mysql uodate 报错 You can't specify target table '**' for update in FROM clause
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 解决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这个表( ...
- 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这个表( ...
- 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 ...
- 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 ...
- 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同一个表的某些值 ...
- MYSQL 1093 之You can't specify target table for update in FROM clause解决办法
You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 出现以上错误,是因为想将表自身的字 ...
随机推荐
- 基于Spring Security OAuth2搭建的Spring Cloud 认证中心
Github传送门:https://github.com/13babybear/bounter-springcloud 实现功能有: 整合JWT 刷新Token 自定义客户端储存 自定义用户储存 资源 ...
- C#多条件查出来的多个DataSet,然后循环将数据整合
private List<string> barList; public List<string> BarList { get ...
- 网页常用Js代码
1.后退前进 <input type="button" value="后退" onClick="history.go(-1)"> ...
- Lua脚本在redis分布式锁场景的运用
目录 锁和分布式锁 锁是什么? 为什么需要锁? Java中的锁 分布式锁 redis 如何实现加锁 锁超时 retry redis 如何释放锁 不该释放的锁 通过Lua脚本实现锁释放 用redis做分 ...
- linux基础命令学习笔记(二)
linux基础命令学习笔记(二) 1.kill :终止进程 kill pid (唯一标示一个进程) kill -9 强制终止 kill -15 命令未结束不能终止 # ps aux 查看所有进程 ...
- Ubuntu 备份系统为ISO镜像 & 解决ISO限制4GB大小 & Clone当前系统到其他电脑
看标题,标题涵盖了3个部分,Ubuntu 备份系统为ISO镜像, 解决ISO限制4GB大小 , Clone当前系统到其他电脑 我们就从三个部分说起. Ubuntu 备份系统为ISO镜像 在Win ...
- Scrapyd 改进第二步: Web Interface 添加 STOP 和 START 超链接, 一键调用 Scrapyd API
0.提出问题 Scrapyd 提供的开始和结束项目的API如下,参考 Scrapyd 改进第一步: Web Interface 添加 charset=UTF-8, 避免查看 log 出现中文乱码,准备 ...
- SSM框架搭建后在tomcat部署报错lineNumber: 15; columnNumber: 59; 必须为元素类型 "beans" 声明属性 "xmlns"
删除applicationContext.xml中的文件头上的这个就可以<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" &q ...
- Cookies的使用之购物车的实现
Cookies的使用之购物车实现 最近学习了JSON对象之后,发现Cookies的使用更加的灵活方便了.ps:JSON不是JS.可以这么理解,JSON 是 JS 对象的字符串表示法,它使用文本表示一个 ...
- P1462 通往奥格瑞玛的道路 最短路
题目背景 在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主城暴风城 在被众多联盟的士兵攻击后,他决定逃回自己的家乡奥格瑞玛 题目描述 在艾泽拉斯, ...