java代码中拼接sql语句的in条件
作者:互联网
/**
* 拼接IN条件值
* @param str
* @return
*/
public static String getInCond(String str) {
String[] strArr = str.split(",");
StringBuffer sb = new StringBuffer();
for(int i = 0;i < strArr.length; i++){
if(i == strArr.length-1){
sb.append("'"+strArr[i]+"'");
}else{
sb.append("'"+strArr[i]+"'"+",");
}
}
return sb.toString();
}
标签:java,String,StringBuffer,strArr,拼接,str,sql,sb,append 来源: https://blog.csdn.net/jianqiangdexiaohai/article/details/95168206