首页 新闻 赞助 找找看

一组数组用表值函数保存起来怎么整呀?

0
悬赏园豆:10 [已解决问题] 解决于 2016-09-28 22:42
 select * from bb where id in('370305104' ,'370305105','370305304','370305305','370305306','370305307')


in 里面的单独拿出来,再在其他语句中引用
andyguo1的主页 andyguo1 | 初学一级 | 园豆:135
提问于:2016-09-28 16:59
< >
分享
最佳答案
0

使用表变量,或临时表

收获园豆:10
悦光阴 | 老鸟四级 |园豆:2251 | 2016-09-28 17:12

怎么整呀?可以给个例子吗?

andyguo1 | 园豆:135 (初学一级) | 2016-09-28 17:41

@andyguo1:  

使用 表变量实现,不谢,

declare @table table
(
id  varchar(10)
)

insert into @table
values('370305104' ,'370305105','370305304','370305305','370305306','370305307')


select * 
from bb a
inner join @table t 
    on a.id=t.id
悦光阴 | 园豆:2251 (老鸟四级) | 2016-09-28 17:57

@悦光阴: 嗯,赶觉有用,是写在函数里的吗?

andyguo1 | 园豆:135 (初学一级) | 2016-09-28 18:00

这样写有点问题,关键是虚拟表建在哪里,多个存储过程要调用这张虚拟表的

andyguo1 | 园豆:135 (初学一级) | 2016-09-28 22:11

自己解决了,看一下吧

andyguo1 | 园豆:135 (初学一级) | 2016-09-28 22:41

@andyguo1: 你这种实现也好

悦光阴 | 园豆:2251 (老鸟四级) | 2016-09-29 09:44
其他回答(1)
0

go

create function bbee ()

returns @points table (x int)

as begin

insert @points

select '1039' union

select '1040' union

select '1041' union

select '1042'

return;

end go

select * from Options where Id in (select * from bbee())

andyguo1 | 园豆:135 (初学一级) | 2016-09-28 22:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册