我有一个问题。
我有一个ProductId产品名列表。
在里面。我有
1-A
2-B
3-C
4-D
如果我愿意select * from products where Id IN (1,2,3,4)
我得到B,D,C,A我怎么得到A,B,C,D
答案 0 :(得分:0)
使用order by
select * from tablename order by ProductName
答案 1 :(得分:0)
您将需要另一个表。
SELECT p.* FROM PRODUCTS p
INNER JOIN
(
SELECT 3 as id, 1 as ord
union all
SELECT 2 as id, 2
union all
SELECT 4 as id, 3
union all
SELECT 1 as id, 4
) O
on o.id=P.productID
order by o.ord