select name,age,sex from A where key in('1','2','3','4','5','6','7','8'),加个索引
转化成连接 try: select name,age,sex from a ,master..spt_values m where a.[key]=m.number and m.type='p' and number between 1 and 8
select [name],age,sex from A a, (select 1 as [key] union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9)b where a.[key]=b.[key]
select [name],age,sex from A a, (select 1 as [key] union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9)b where a.[key]=b.[key]转换为union 然后在KEY字段加索引
转化成连接 try:
select name,age,sex from a ,master..spt_values m where a.[key]=m.number and m.type='p' and number between 1 and 8
(select 1 as [key] union select 2
union select 3
union select 4
union select 5
union select 6
union select 7
union select 8
union select 9)b
where a.[key]=b.[key]
[name],age,sex from A a,
(select 1 as [key]
union select 2
union select 3
union select 4
union select 5
union select 6
union select 7
union select 8
union select 9)b
where
a.[key]=b.[key]转换为union 然后在KEY字段加索引