This question already has answers here:
PreparedStatement IN clause alternatives?
                                
                                    (30个答案)
                                
                        
                去年关闭。
            
        

我有一个要传递给SQL语句的List<Long> matchingLongs = new Arraylist();

WHERE Id IN (matchingLongs);


如何动态地将Longs填充到查询中?

如果我要打印到控制台,它应该看起来像:

WHERE Id IN (1223, 9834, 3, 924, 88778, 65652165223, 34, 8723738793287);


谢谢你们。

最佳答案

我认为您应该迭代matchingLongs,然后将每个项目添加到新字符串中。

09-11 05:48