查询student表中年龄最大的,并将它的name改成"十五岁"mysql
update 表名 set name = 十五岁 where age = ( select max(age) from 表名)
结果运行时报异常:You can't specify target table 'student' for update in FROM clausesql
这个异常的意思就是spa
第二层查询的FROM子句中的表,不能做为更新的目标表。即不能对同一张表的查询结果做为本表增删改的判断条件code
update 表名 set name = 十五岁 where age =( select t.age from ( select max(age) as num from 表名) t)
即不能对一张表的查询结果做为本表增删改的判断条件blog
select出的结果再经过中间表select一遍,这样就规避了错误。ci