[英]Taking rows from temp-table and using for IN statement
My last post had issues. 我的上一个帖子有问题。 Alright, I have a temp table that has multiple rows of numbers:
好了,我有一个临时表,其中包含多行数字:
It gets saved into a table variable: 它被保存到一个表变量中:
DECLARE @VALUE varchar(500) = '482';
DECLARE @CONTRACT_MEMBER_BRG_ATTR_ITEM_IDS TABLE
(
item_id nvarchar(100)
);
INSERT INTO @CONTRACT_MEMBER_BRG_ATTR_ITEM_IDS
SELECT item_id
FROM [CONTRACT_MEMBER_BRG]
WHERE member_item_id = @VALUE
I need to take all of these values and put it into an in statement in my another query: 我需要将所有这些值都放入另一个查询中的in语句中:
SELECT *
FROM
(complicated SELECT query) a
WHERE
item_id IN (8086, 8087, 8088, 8089, 8090, 8091, 8092);
How would I add all of the rows to a variable that could be used in an IN statement? 如何将所有行添加到可以在IN语句中使用的变量中?
... where id in (select id from temp_table where...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.