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.
如何组合 MySQL 查询以删除列数据等于其他表的 SELECT 的表上的行?
我想: DELETE FROM debts WHERE name = (SELECT name FROM payers)
DELETE FROM debts WHERE name = (SELECT name FROM payers)
而不是使用=,将其更改为,IN因为子查询可以返回多行。
=
IN
DELETE FROM debts WHERE name IN (SELECT name FROM payers)
但我更喜欢JOIN表格而不是使用IN.
JOIN
DELETE a FROM debts a INNER JOIN payers b ON a.name = b.name