public static void main(String[] args) {
String sql="select * from p_Enterprise where 1=1";
String[] str=new String[]{"江苏徐州","无锡新区"};
sql+=" and fAddress in (";
for (int i = 0; i <str.length-1; i++) {
sql+="'"+str[i]+"',";
}
sql+="'"+str[str.length-1]+"')";//去掉最后一个逗号
System.out.println(sql);
}
---生成的SQL
select * from p_Enterprise where 1=1 and fAddress in (' 江苏徐州 ',' 无锡新区 ')