首页 > 解决方案 > 在 postgres 查询中使用 List

问题描述

我有一个动态列表。

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

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

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

我想将列表值传递给这个查询

我怎么能这样做.. ??? 请帮忙谢谢

标签: sqlpostgresql

解决方案


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

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

或者

where name = any (list_parameter)

推荐阅读