Reputation: 969
I am writing a stored procedure like this:
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
My problem is sub query passing 2 or more values (select AccountNumber from tblInvAccountDetails where AccountTypeID = 10 and 20)
so I will compare both accountnumbers (1000, 10003, 1006)
based on AccountTypeID = 10 and 20
How can I write the stored procedure please?
Thank You
hemanth
Upvotes: 0
Views: 70
Reputation: 432210
Use IN
not =
...
where
CustomerID=@CustomerID
or
CustomerID=''
and
AccountNumber IN (select AccountNumber from tblInvAccountDetails where AccountTypeID IN (10, 20))
Note:
(
and )
somewhereUpvotes: 2