我正在编写一个存储过程,如下所示:
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),所以我将基于AccountTypeID = 10 and 20比较这两个accountnumbers (1000, 10003, 1006)
请告诉我如何编写存储过程?
谢谢
赫曼思
发布于 2011-06-20 14:44:43
使用IN而不是=
...
where
CustomerID=@CustomerID
or
CustomerID=''
and
AccountNumber IN (select AccountNumber from tblInvAccountDetails where AccountTypeID IN (10, 20))注意:
(和) https://stackoverflow.com/questions/6407651
复制相似问题