gpt4 book ai didi

java - 如何在where条件下传递多个搜索值

转载 作者:行者123 更新时间:2023-11-29 20:11:04 24 4
gpt4 key购买 nike

我在我的java程序中连接到数据库。我有一种情况,我需要动态传递过滤器值,过滤器值取决于java代码的其他部分

示例查询:select * from table1 where id in(动态和多个)?

如何使用 Java 连接传递这些动态和多个值。

最佳答案

试试这个

String query =  "select * from emp where id in(##)";

像这样创建 in 子句

String inClause = "'abcd', 'cedf', '1234'";

String finalQuery = query.replace("##", inClause );

关于java - 如何在where条件下传递多个搜索值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40115879/

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