gpt4 book ai didi

postgresql - 带参数查询 IN 子句

转载 作者:行者123 更新时间:2023-11-29 12:35:28 25 4
gpt4 key购买 nike

这是我的查询,

<Request method="GET">
<Query>
select user_id from user
where user_type in ($userTypes)
</Query>
</Request>

如何在 metamug 资源文件中为此参数 $userType 发送多个值。我正在使用 GET 请求。我的数据库是 postgres。

$userTypes 是 ID 列表。我可以在请求中将其作为逗号分隔的字符串“1501,1502,1503”传递。

谢谢。

最佳答案

你可以使用:

select user_id from user
where user_type in (SELECT unnest(string_to_array($userTypes, ',')));

DbFiddle Demo

关于postgresql - 带参数查询 IN 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48355567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com