使用Java 8及以上版本: String inClause = list.stream().map(id-> String.valueOf(id)).collect(toStringJoiner(",")); String sql = "select name from tbl where name in (" + inClause + ")";