How is it possible to loop over a set of selected results in a stored procedure and take out the ones that match a criteria.
If it shouldn't need a loop or something of the sort how would I achieve this?
So lets say we have a select statement like so
SELECT DefaultID, Weight, Length, Height, Width FROM tblDefault
WHERE CustomerID=@CustomerID AND DeleteDateUTC is null
But how can I get only the rows that also match the criteria
IF SELECT 1 FROM tblOther WHERE CustomerID=@CustomerID AND CustomerUserID=CustomerUserID
AND DefaultID=@DefaultID returns 1 row
OR SELECT 1 FROM tblOther WHERE CustomerID=@CustomerID AND DefaultID=@DefaultID returns nothing
In short I am wanting to select rows in tblDefault
where the defaultID
is in tblOther
with the CustomerUserID
or the defaultID
isn't in tblOther