code: public String buildUnionQuery(String[] subQueries, String sortOrder, String limit) {
          StringBuilder query = new StringBuilder(128);
          int subQueryCount = subQueries.length;
          String unionOperator = mDistinct ? " UNION " : " UNION ALL ";
  
          for (int i = 0; i < subQueryCount; i++) {
              if (i > 0) {
                  query.append(unionOperator);
              }
              query.append(subQueries[i]);
          }
          appendClause(query, " ORDER BY ", sortOrder);
          appendClause(query, " LIMIT ", limit);
          return query.toString();
      }
docs: Given a set of subqueries, all of which are SELECT statements,
  construct a query that returns the union of what those
  subqueries return.
  @param subQueries an array of SQL SELECT statements, all of
  which must have the same columns as the same positions in
  their results
  @param sortOrder How to order the rows, formatted as an SQL
  ORDER BY clause (excluding the ORDER BY itself).  Passing
  null will use the default sort order, which may be unordered.
  @param limit The limit clause, which applies to the entire union result set
  
  @return the resulting SQL SELECT statement