2010-12-01 MySQLでサブクエリ MySQL <div class="section"> 動かないSQL DELETE FROM hoge WHERE id NOT IN (SELECT id FROM hoge); 動くSQL DELETE FROM hoge WHERE id NOT IN (SELECT id FROM (SELECT id FROM hoge) a); なにやらテンポラリテーブルを挟まないと動いてくれない模様。 そういや昔なんかでみたなー 参考 http://wsjp.blogspot.com/2009/12/mysql1093.html