MySQL-[HY000][1093] You can't specify target table 't_hisen' for update in FROM clause

[HY000][1093] You can't specify target table 't_hisen' for update in FROM clause

原因:

update t_hisen
set name = 'hisen'
where id in (select id from t_hisen where age = 18)

类似上面的sql,mysql update不允许表名既在update中又在子查询中。
Oracle是可以的

解决办法只有先查询,在拿出数据放在where子句中

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容