我有一个生成结果的查询:
SELECT urenID FROM uren WHERE uren.urenDossierID IN (SELECT dossierID FROM dossier WHERE dossierKlantID NOT IN (SELECT klantID from klant))
现在我想删除生成该查询的所有记录。现在是我的问题;怎么做?
答案 0 :(得分:2)
只需将SELECT urenID
替换为DELETE
DELETE FROM uren WHERE uren.urenDossierID IN (SELECT dossierID FROM dossier WHERE dossierKlantID NOT IN (SELECT klantID from klant))
答案 1 :(得分:1)
试试这个。
DELETE FROM uren WHERE urenID in (
SELECT urenID FROM uren WHERE uren.urenDossierID IN (SELECT dossierID FROM dossier WHERE dossierKlantID NOT IN (SELECT klantID from klant)))
答案 2 :(得分:1)
我坚信JOIN
比IN
DELETE a
FROM uren a
LEFT JOIN dossier b
ON a.urenDossierID = b.dossierID
LEFT JOIN klant c
ON b.dossierKlantID = c.klantID
WHERE b.dossierID IS NOT NULL AND
c.klantID IS NULL