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);
哪个应该起作用,我想知道子查询是否是执行此操作的最佳方法/还有其他方法吗?
我更喜欢使用JOINover subquery。
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