惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
量子位
Martin Fowler
Martin Fowler
月光博客
月光博客
P
Proofpoint News Feed
博客园_首页
Y
Y Combinator Blog
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
H
Help Net Security
U
Unit 42
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - ssnice

AI使用总结 常见问题汇总 常见linux命令 nlog sqlserver 定时自动备份 sqlserver 常见语法 mysql 常用命令(linux) mysql 连接数 最大并发数 windows mysql 主从同步 mysql基础语法 windows mysql8 安装 VS2022安装后,使用VS2019打开项目,出现无法找到.NET SDK的问题解决 Asp .Net Mvc5 缓存 DataBase First创建数据库 OpenXML_导入Excel到数据库 Linq/List/Array/IEnumerable等集合操作 js中substring/substr和C#中Substring的用法 Code First研究学习2_基本的错误及解决方法 C#中静态构造函数含义及使用
mysql出现 You can't specify target table 'xx'...
ssnice · 2023-02-20 · via 博客园 - ssnice

在执行如下更新语句的时候,提示如下问题: You can't specify target table 'outorder' for update in FROM clause 0.000 sec, 大体翻译出来的意思是: 不能先select出同一表中的某些值,再update这个表(在同一语句中)
update outorder set SchoolId = 5,canteenid = 4 where BillId in ( select BillId from outorder where CanteenId = 6 );
解决方案:将查询出来的数据集放在一个表中,类似如下语句
SELECT a.BillId FROM (select BillId from outorder where CanteenId = 6) a
最终的语句调整为如下格式
update outorder set SchoolId = 5,canteenid = 4 where BillId in ( SELECT a.BillId FROM (select BillId from outorder where CanteenId = 6) a );