我正在编写这样的存储过程:
create PROC uspInvCustomerLineItemGetList1(@CustomerID varchar(50))
AS
BEGIN
SELECT LineItemID, LineItemName
from tblInvoiceLineItems
where CustomerID = @CustomerID
or CustomerID = ''
and AccountNumber = (select AccountNumber from tblInvAccountDetails
where AccountTypeID = 10 and 20)
END
我的问题是子查询传递了2个或更多值(select AccountNumber from tblInvAccountDetails where AccountTypeID = 10 and 20)
,因此我将根据accountnumbers (1000, 10003, 1006)
比较AccountTypeID = 10 and 20
我该如何编写存储过程?
谢谢
hemanth
答案 0 :(得分:2)
使用IN
而不是=
...
where
CustomerID=@CustomerID
or
CustomerID=''
and
AccountNumber IN (select AccountNumber from tblInvAccountDetails where AccountTypeID IN (10, 20))
注意:
(
和)
某处