Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
表1:
表 2:
基本的にやりたいことは
Delete from table_1 where id not in (select table_1_id from table_2 group by table_1_id);
サブクエリがこれを行うための最良の方法であるかどうか、または他の方法はありますか?
subqueryJOINよりも使用することを好みます。
JOIN
DELETE a FROM table_a a LEFT JOIN table_2 b ON a.ID = b.table_1_id WHERE b.table_1_id IS NULL