我想从一个使用参数化sql查询的集合中搜索一个特定的值,不管它是什么,或者不是这个的SQL查询
答案 0 :(得分:0)
据我所知,prepareStatement不能使用逗号分隔的IN()
子句列表。
您可以使用以下简单的内容:
private static final domainListPlaceHolder = "<DOMAINS_LIST>";
String sql = "select p.DEALER_NAME from DEALER_PROFILE as p,DEALER_DOMAIN as d,
DELER_PROFILE_DOMAIN as pd where d.DOMAIN_ID = pd.DOMAIN_ID
and d.DOMAIN_NAME IN (<DOMAINS_LIST>) and pd.DEALER_ID= p.DEALER_ID";
// build a comma delimited String from your array (each domain wrapped with ''), called domainList
String sqlToRun = sql.replace(domainListPlaceHolder, domainList);