我想将变量数参数传递给sql查询。举个例子:
select column1
from Table
where column2 in ( '0080','0010')
group by column1
having count(distinct column2) >= 2
在where子句中,使用了2个参数0080
和0010
。但是这些参数可以根据用户的输入而变化。作为一个例子,它可能是这样的:
select column1
from Table
where column2 in ( '0080','0010', '0020', '0050', '0060')
group by column1
having count(distinct column2) >= 5
因此,这些参数数量不固定,用户将从 .xml
文件中传递。
我们如何向查询传递可变数量的参数?由于参数的数量不固定且可以不时更改,我们可以使用数组或类似的东西吗?
答案 0 :(得分:1)
我建议你尝试将参数加载到临时表中,并在子查询的where子句中使用它。特别是如果你的参数列表变得非常大,这就更具可扩展性。