34,873
社区成员
发帖
与我相关
我的任务
分享
select a from 表 where a="xx"
union all select a from 表 where a="zz"
union all select a from 表 where a="yy"
declare @mytb table(col1 char(3),col2 char(2),col3 decimal(3,0))
insert @mytb select 'xx','ac',3 union
select 'yy','ad',5 union
select 'zz','ab',6 union
select 'aa','b4',7 union
select 'bb','a4',8
select * from @mytb where (col2='ab' or col2='ac' or col2='ad') order by col2
select
a
from
tb
where
a='xx' or a='zz' or a='yy'
order by
charindex(a,'xx,zz,yy')declare @a varchar(10),@b varchar(10),@c varchar(10),@s varchar(8000)
set @a='xx'
set @b='zz'
set @c='yy'
set @s='select a from 表 where ( a='''+@a+''' or a='''+@b+''' or a='''+@c+''')'
+' order by charindex(a,''@a+@b+@c'')'
exec (@s)select a from 表 where (a='xx' or a='yy' or a='zz')
order by a
select a from 表 where (a='xx' or a='zz' or a='yy')
order by case a when 'xx' then 1 when 'zz' then 2 else 3 end
select a from 表 where (a='xx' or a='yy' or a='zz')
ORDER BY CHARINDEX(A,'XX,ZZ,YY')select a from 表 where (a='xx' or a='yy' or a='zz')
ORDER BY A ?