Skip to content

Structure

SQLUnion

An expression representing two or more SELECT queries joined by UNION clauses. Used to merge the results of multiple queries into a single result set.
struct SQLUnion

Overview

(SELECT ...)
UNION ALL
(SELECT ...)
INTERSECT DISTINCT
(SELECT ...)
EXCEPT ALL
(SELECT ...)

There are numerous variations in support and syntax for UNION joiners between dialects; this expression respects dialect differences to the extent possible but will someimtes generate invalid SQL if an operation unsupported by the current dialect is described by its inputs.

See SQLUnionBuilder.

Topics

Initializers

Instance Properties

  • initialQuery
    The required first query of the union.
  • limit
    If not nil, limits the number of result rows returned. Applies after offset (if specified).
  • offset
    If not nil, skips the given number of result rows before starting to return results.
  • orderBys
    Zero or more columns or expressions specifying sort keys and directionalities for the overall result rows.
  • tableExpressionGroup
    An optional common table expression group.
  • unions
    Zero or more additional queries whose results are to be combined with that of the initial query and associated joiner expressions describing the combining operation.

Instance Methods

  • add(_:all:)
    Add an additional query to the union using the UNION or UNION ALL joiner.
  • add(_:joiner:)
    Add an additional query to the union using the provided joiner.
  • serialize(to:)
    Invoked when a request is made to serialize the expression to raw SQL.

Relationships

Conforms To

See Also

Query Expressions

  • SQLAlterEnum
    An expression representing an ALTER TYPE query. Used to add new cases to enumeration types.
  • SQLAlterTable
    An expression representing an ALTER TABLE query. Used to modify the structure of existing tables.
  • SQLCreateEnum
    An expression representing a CREATE TYPE query. Used to create enumeration types.
  • SQLCreateIndex
    An expression representing a CREATE INDEX query. Used to add indexes over columns to an existing table.
  • SQLCreateTable
    An expression representing a CREATE TABLE query. Used to create new tables.
  • SQLCreateTrigger
    An expression representing a CREATE TRIGGER query. Used to create new triggers for actions on a table.
  • SQLDelete
    An expression representing a CREATE TRIGGER query. Used to remove rows from a table.
  • SQLDropEnum
    An expression representing a DROP TYPE query. Used to delete enumeration types.
  • SQLDropIndex
    An expression representing a DROP INDEX query. Used to delete indexes from tables.
  • SQLDropTable
    An expression representing a DROP TABLE query. Used to delete entire tables.
  • SQLDropTrigger
    An expression representing a DROP TRIGGER query. Used to delete triggers.
  • SQLInsert
    An expression representing an INSERT query. Used to add new rows to a table.
  • SQLSelect
    An expression representing a SELECT query. Used to retrieve rows and expression results from a database.
  • SQLUpdate
    An expression representing an UPDATE query. Used to modify existing rows in a single table.