22,210
社区成员
发帖
与我相关
我的任务
分享
select
*
from
t
where
id in (3,2,5,4,7,6)
order by
charindex(ltrim(id),'3,2,5,4,7,6')
SELECT * FROM t WHERE ID in (3,2,5,4,7,6)
ORDER BY CHARINDEX(LTRIM(id),'3,2,5,4,7,6')
DECLARE @TB TABLE(ID INT)
INSERT INTO @TB
SELECT 3
UNION ALL
SELECT 2
UNION ALL
SELECT 5
UNION ALL
SELECT 4
UNION ALL
SELECT 7
UNION ALL
SELECT 6
SELECT T.ID,A.NAME FROM @TB T
LEFT JOIN A
ON T.ID=A.ID
select id,name from A where ID =3
union all
select id,name from A where ID =2
union all
select id,name from A where ID =5
union all
select id,name from A where ID =4
union all
select id,name from A where ID =7
union all
select id,name from A where ID =6
select * from A where ID =3
union all
select * from A where ID =2
union all
select * from A where ID =5
union all
select * from A where ID =4
union all
select * from A where ID =7
union all
select * from A where ID =6