尝试使用子查询删除行时出现错误:
DELETE FROM tblOrderDetails
WHERE ProductID = (SELECT ProductID FROM tblProducts WHERE Discontinued = 1)
我理解的错误是:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
我知道子查询返回多个值,但是如何删除这些行 谢谢任何帮助,将不胜感激。 帕特里克
最佳答案
试试这个
DELETE FROM tblOrderDetails
WHERE ProductID IN (
SELECT ProductID
FROM tblProducts
WHERE Discontinued = 1
)
关于SQL Server DELETE 错误 - 子查询返回超过 1 个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6405096/