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();
}

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 ( ) ; }
given a set of subqueries , all of which are select statements , construct a query that returns the union of what those subqueries return .
