sql - 在 postgres 查询中使用 List
问题描述
我有一个动态列表。
list=['a','b','c','d' ..... ]
所以长度可能会改变
我想在查询中比较这些列表值
select * from student where name in(all the list values);
我想将列表值传递给这个查询
我怎么能这样做.. ??? 请帮忙谢谢
解决方案
在 Postgres 中,您可以使用数组。where
子句中的语法如下所示:
where name = any (array[1, 2, 3])
或者
where name = any (list_parameter)
推荐阅读
- git - Git - 恢复提交
- php - php:sql错误“错误:带有查询的'where子句'中的未知列'RM'”
- jenkins - 仅当有新版本的文件时才从其他作业复制工件
- entity-framework - 在 Union-Query 中选择子集合
- ajax - 动态删除购物车费用 Woocommerce
- sql - 在 where 子句中带有“IN”的 SQL 查询运行速度非常慢
- linux - CMake 创建 Visual Studio Code 项目
- java - 添加一个 BoardView 扩展 View 类到一个线性布局
- r - R,如何在ggplot2中叠加两个geom_bars?
- chromecast - Android上Chrome的Chromecast发件人应用程序失败