SQL build In Clause - Android java.lang

Android examples for java.lang:StringBuilder

Description

SQL build In Clause

Demo Code


public class Main{

    public static String buildSqlInClause(String keyword, String value) {
        StringBuilder sb = new StringBuilder();
        sb.append(" (").append(keyword).append(" is not null and (");
        sb.append(keyword + "='" + value + "'");
        sb.append(" or ").append(keyword + " like '%," + value + ",%'");
        sb.append(" or ").append(keyword + " like '%," + value + "'");
        sb.append(" or ").append(keyword + " like '" + value + ",%'");
        sb.append(")) ");
        return sb.toString();
    }//  www .  ja v a  2  s .  c  om

}

Related Tutorials