我需要删除所有没有分配许可证的贡献者
Table : Columns
Contributors : [id, Name,...]
Licenses : [id, ContributorId, Name, ...]
像这样
DELETE FROM Contributors
WHERE
License.ContributorId != Contributor.Id
最佳答案
DELETE FROM Contributors
WHERE NOT EXISTS (
SELECT *
FROM License
WHERE License.ContributorId = Contributors.Id)
关于sql - 从表中删除没有引用 ID 的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5085847/