0

我有一个生成结果的查询:

SELECT urenID FROM uren WHERE uren.urenDossierID IN (SELECT dossierID FROM dossier WHERE dossierKlantID NOT IN (SELECT klantID from klant))

现在我想删除生成该查询的所有记录。现在是我的问题;怎么做?

4

3 回答 3

2

只需替换SELECT urenIDDELETE

DELETE FROM uren WHERE uren.urenDossierID IN (SELECT dossierID FROM dossier WHERE dossierKlantID NOT IN (SELECT klantID from klant))
于 2013-02-02T13:47:08.090 回答
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)))
于 2013-02-02T13:47:06.967 回答
1

我坚信JOININ

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
于 2013-02-02T13:53:59.240 回答