funmain(args: Array<String>){val ids:List<Int>=listOf(1,2,3,4,5);var sql ="select id, geomSelectStatement as geom, properties from tableName where tenant = DEFAULT"val idCondition = ids.joinToString(" or "){"id = $it"}
sql +=" and ($idCondition)"println(sql)}//select id, geomSelectStatement as geom, properties from tableName where tenant = DEFAULT and (id = 1 or id = 2 or id = 3 or id = 4 or id = 5)
组装in语句
funmain(args: Array<String>){val ids:List<Int>=listOf(1,2,3,4,5);var sql ="select id, geomSelectStatement as geom, properties from tableName where tenant = DEFAULT"val idCondition = ids.joinToString(",")
sql +=" and id in ($idCondition)"println(sql)}//select id, geomSelectStatement as geom, properties from tableName where tenant = DEFAULT and id in (1,2,3,4,5)
组装or语句fun main(args: Array<String>) { val ids:List<Int> = listOf(1,2,3,4,5); var sql = "select id, geomSelectStatement as geom, properties from tableName where tenant = DEFAULT" val idCondition = ids.joinToString(" or "){ "id = $it