/** * Accepts a SELECT type queryset and builds a union select between them. * * @param qs A select type queryset * @return */ public QuerySet union(QuerySet qs) throws SQLException { hasRan(); unionSet = (unionSet == null) ? "\nUNION " + qs.compileSelect() : unionSet + "\nUNION " + qs.compileSelect(); unionData.addAll(qs.getData()); sourceTables.addAll(qs.getSourceTables()); return this; }
/** * Builds a composite FROM part of the query. * * @param qs A QuerySet that produces data (a SELECT) * @param alias The alias for the intermediate table * @return queryset */ public QuerySet from(QuerySet qs, String alias) throws SQLException { hasRan(); if (fromSet == null) { fromSet = "\nFROM (" + qs.compileSelect() + ") AS " + alias + " "; } else { fromSet = ", (" + qs.compileSelect() + ") AS " + alias + " "; } fromData.addAll(qs.getData()); sourceTables.addAll(qs.getSourceTables()); return this; }
public QuerySet whereNotIn(String column, QuerySet innerQuery, String type) throws SQLException { hasRan(); if (whereSet == null) { whereSet = "\nWHERE "; } else { whereSet += "\n" + type + " "; } whereSet += column + " " + LogicOperands.NOT_IN + " (" + innerQuery.compileSelect() + ")"; whereData.addAll(innerQuery.getData()); sourceTables.addAll(innerQuery.getSourceTables()); return this; }