Databases MSSQL Retake Exam - 15 December 2016 -Section 2. DML 4. Delete
Как се решава 4-та задача?
DELETE FROM Locations
WHERE Id IS NULL
дава 2/5
DELETE FROM Locations
WHERE Id NOT IN (SELECT LocationId FROM Users)
пак дава 2/5
DELETE FROM Locations
WHERE Id IS NULL
дава 2/5
DELETE FROM Locations
WHERE Id NOT IN (SELECT LocationId FROM Users)
пак дава 2/5
Ето едно решение от мен
DELETE FROM Locations
WHERE Id IN (
SELECT l.Id
FROM Locations AS l
LEFT JOIN Users AS u ON u.LocationId = l.Id
WHERE u.Id IS NULL
)