拼接sql

String whereArgs = taskTable + " where 1=1 ";

if (upCheck) {
whereArgs += " and type = 2 ";
}
if (gameID != null && !gameID.equals("0")) {
whereArgs += " and gameID = " + gameID;
}
if (searchProjectkey != null && !searchProjectkey.trim().equals("")) {
whereArgs += " and projectID like " + "'%" + searchProjectkey
+ "%'";
}
if (searchChannelkey != null && !searchChannelkey.trim().equals("")) {
whereArgs += " and channelName like " + "'%" + searchChannelkey
+ "%'";
}

life is a jounery,yes
原文地址:https://www.cnblogs.com/CaptainLin/p/4166927.html