每一年都奔走在自己热爱里

没有人是一座孤岛,总有谁爱着你

1093 - You can't specify target table 'basic_teacher_info' for update in FROM clause

1. 错误sql

delete from test where age = (SELECT max(age) from test)

2. 错误原因

1093 - You can't specify target table 'basic_teacher_info' for update in FROM clause     

含义:不能将同一表中查询的数据作为同一表的更新的数据。

大致意思是,在同一语句中,不能先select出同一表中的某些值,再update这个表

3. 解决方法

正确sql:查询的时候增加一层中间表,就可以避免该错误。

delete from test where age = ( select a.age from (SELECT max(age) from test) a)
posted @ 2021-05-19 10:03  helloliyh  阅读(86)  评论(0编辑  收藏  举报