11 ERROR:1093を回避

update の時同じテーブルに対するサブクエリからの操作ができない

update hoge set code = 0
where id IN 
(select id from hoge as tmp where id = 1 group by id  order by id)
;

ERROR 1093 (HY000): You can't specify target table 'hoge' for update in FROM clause

対応

これで上手くいく

update hoge set code = 0
where id IN (
select id from 
(select id from hoge where id = 1 group by id  order by id) as tmp
)
;