Java tutorial
//package com.java2s; import java.util.List; public class Main { static private void parseParam(String src, String field, StringBuffer params, List<String> args) { if ("*".equals(src)) { return; } if (params.length() > 0) { params.append(" AND"); } if (src.indexOf(",") == -1) { params.append(" " + field + "=?"); args.add(src); } else { String[] weekdays = src.split(","); StringBuffer weekdaysParams = new StringBuffer(); for (int i = 0; i < weekdays.length; ++i) { if (i > 0) { weekdaysParams.append(","); } weekdaysParams.append("?"); args.add(weekdays[i]); } params.append(" " + field + " IN (" + weekdaysParams.toString() + ")"); } } }