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

推荐订阅源

博客园 - 聂微东
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
M
MIT News - Artificial intelligence
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
P
Proofpoint News Feed
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理

博客园 - 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 );