言诗把酒

关注

mysql delete/update select查询的数据

言诗把酒

关注

阅读 84

2022-03-14

delete from user where id in (select id from user where id < 100)

这样写会报错:You can't specify target table 'student' for update in FROM clause

如果删除/更新和子查询使用同一张表会报上述错误

解决方法:起别名
delete from user where id in (select a.id from (select id from user where id < 100) a )

相关推荐

吴wuwu

[MySQL]mysql update select 从查询结果中更新数据

吴wuwu 72 0 0

前行的跋涉者

JavaScript Json Create、Select、Delete、Update

前行的跋涉者 161 0 0

爱薇Ivy趣闻

mysql update select

爱薇Ivy趣闻 188 0 0

捌柒陆壹

增(INSERT)、删(DELETE)、改(UPDATE)、查(SELECT),

捌柒陆壹 103 0 0

苦茶如歌

SQL——数据操纵语言DML(INSERT,UPDATE,DELETE)、数据查询语言DQL(SELECT)、操作符

苦茶如歌 54 0 0

微言记

MySQL update select 结果

微言记 162 0 0

杰森wang

【mysql】mysql之数据操作语言(insert、delete、update)

杰森wang 13 0 0

Soy丶sauce

【MySQL基本查询】Create(创建), Retrieve(读取),Update(更新),Delete(删除)

Soy丶sauce 81 0 0

爱写作的小土豆

Mysql数据库 | 第三章 | insert | update | delete | select | 统计函数 | 分组统计

爱写作的小土豆 8 0 0

_karen

MySQL数据操作与查询- select 数据查询

_karen 34 0 0

精彩评论(0)

0 0 举报