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子句中

你可能感兴趣的:(MySQL-[HY000][1093] You can't specify target table 't_hisen' for update in FROM clause)