I have a table structure like this.
ProductCR productID ProductName
09 1553 A1
09 1600 A2
09 1800 A3
10 1553 A4
10 1600 A5开发者_Go百科
10 2000 A6
I want to make something like this:
Select ProductoName from Products where (ProductCR,ProductID) in ((09,1553),(10,1600),(10,2000))
Result:
A1
A5
A6
Is this posible in Sql Server?? such a "select in" with "ordered pairs"?? Thanks, Victor.
It is not possible. I this this is a good option:
DECLARE @orderedPairs TABLE (cr int, id int)
INSERT INTO @orderedPairs (cr, id)
VALUES (09,1553),(10,1600),(10,2000)
SELECT ProductName
FROM Products
join @orderedPairs on ProductCR = cr
and ProductID = id
Oracle allows that, but SQL Server does not. You'll have to write it out:
select ProductoName
from Products
where ProductCR = 09 and ProductID = 1553 or
ProductCR = 10 and ProductID = 1600 or
ProductCR = 10 and ProductID = 2000
精彩评论