在Postgres查询中使用List

时间:2019-03-04 10:15:38

标签: sql postgresql

我有一个动态列表。

list=['a','b','c','d' ..... ],因此长度可能会改变

我想在查询中比较这些列表值

select * from student where name in(all the list values);

我想将列表值传递给该查询

我该怎么做.. ???请帮忙 谢谢

1 个答案:

答案 0 :(得分:0)

在Postgres中,您可以使用数组。 where子句中的语法如下:

where name = any (array[1, 2, 3])

where name = any (list_parameter)