# Union

class Union(firstStatement: AbstractQuery<*>, val secondStatement: AbstractQuery<*>) : SetOperation

Represents an SQL operation that combines all results from two queries, without any duplicates.

## Constructors

Union
Link copied to clipboard
constructor(firstStatement: AbstractQuery<*>, secondStatement: AbstractQuery<*>)

## Properties

fetchSize
Link copied to clipboard
var fetchSize: Int?

The number of results that should be fetched when this query is executed.

firstStatement
Link copied to clipboard
val firstStatement: AbstractQuery<*>

The SQL statement on the left-hand side of the set operator.

isAlwaysBatch
Link copied to clipboard
open val isAlwaysBatch: Boolean

Whether the SQL statement is meant to be performed as part of a batch execution.

limit
Link copied to clipboard
var limit: Int?

The stored value for a `LIMIT` clause in this query.

offset
Link copied to clipboard
var offset: Long

The stored value for an `OFFSET` clause in this query.

operationName
Link copied to clipboard
open val operationName: String

The SQL keyword representing the set operation.

orderByExpressions
Link copied to clipboard
var orderByExpressions: List<Pair<Expression<*>, SortOrder>>

The stored list of columns and their SortOrder for an `ORDER BY` clause in this query.

secondStatement
Link copied to clipboard
val secondStatement: AbstractQuery<*>
set
Link copied to clipboard
open override val set: FieldSet

The set of columns on which a query should be executed, contained by a ColumnSet.

targets
Link copied to clipboard
val targets: List<Table>
type
Link copied to clipboard
val type: StatementType

## Functions

appendTo
Link copied to clipboard
fun <T> Iterable<T>.appendTo(builder: QueryBuilder, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", transform: QueryBuilder.(T) -> Unit): QueryBuilder

Appends all the elements separated using separator and using the given prefix and postfix if supplied.

arguments
Link copied to clipboard
open override fun arguments(): List<List<Pair<IColumnType<*>, Any?>>>

Returns all mappings of columns and expression types to their values needed to prepare an SQL statement.

copy
Link copied to clipboard
open override fun copy(): Union

Returns a new SizedIterable that is a copy of the original.

copyTo
Link copied to clipboard
open fun copyTo(other: SetOperation)

Copies all stored properties of this `SELECT` query into the properties of other.

count
Link copied to clipboard
open override fun count(): Long

Returns the number of results retrieved after query execution.

empty
Link copied to clipboard
open override fun empty(): Boolean

Returns whether any results were retrieved by query execution.

except
Link copied to clipboard
fun AbstractQuery<*>.except(other: Query): Except

Returns only distinct results from this query that are NOT common to the results of other.

execute
Link copied to clipboard
fun execute(transaction: Transaction): ResultSet?

Executes the SQL statement directly in the provided transaction and returns the generated result, or `null` if either no result was retrieved or if the transaction blocked statement execution.

executeInternal
Link copied to clipboard
open override fun PreparedStatementApi.executeInternal(transaction: Transaction): ResultSet

Determines the exact way that an SQL statement is executed in a transaction and applies any necessary logic before returning the result generated by the executed statement.

fetchSize
Link copied to clipboard
fun fetchSize(n: Int): SetOperation

Modifies the number of results that should be fetched when this query is executed.

forEach
Link copied to clipboard
open fun forEach(p0: Consumer<in ResultRow>)
forUpdate
Link copied to clipboard
open fun forUpdate(option: ForUpdateOption = ForUpdateOption.ForUpdate): SizedIterable<ResultRow>

Returns a new SizedIterable with a locking read for the elements according to the rules specified by option.

intersect
Link copied to clipboard
fun AbstractQuery<*>.intersect(other: Query): Intersect

Returns only results from this query that are common to the results of other, WITHOUT including any duplicates.

iterator
Link copied to clipboard
open operator override fun iterator(): Iterator<ResultRow>
limit
Link copied to clipboard
open override fun limit(count: Int): SetOperation

Modifies this query to return only count results.

open override fun limit(n: Int, offset: Long): SetOperation
mapLazy
Link copied to clipboard
infix fun <T, R> SizedIterable<T>.mapLazy(f: (T) -> R): SizedIterable<R>

Returns a SizedIterable containing the lazily evaluated results of applying the function f to each original element.

notForUpdate
Link copied to clipboard
open fun notForUpdate(): SizedIterable<ResultRow>

Returns a new SizedIterable without any locking read for the elements.

offset
Link copied to clipboard
open override fun offset(start: Long): SetOperation

Modifies this query to return only results starting after the specified start.

orderBy
Link copied to clipboard
open override fun orderBy(vararg order: Pair<Expression<*>, SortOrder>): SetOperation

Modifies this query to sort results according to the provided order of expressions.

fun orderBy(column: Expression<*>, order: SortOrder = SortOrder.ASC): SetOperation

Modifies this query to sort results by the specified column, according to the provided order.

prepared
Link copied to clipboard
open fun prepared(transaction: Transaction, sql: String): PreparedStatementApi

Uses a transaction connection and an sql string representation to return a precompiled SQL statement, stored as an implementation of PreparedStatementApi.

prepareSQL
Link copied to clipboard
open override fun prepareSQL(transaction: Transaction, prepared: Boolean): String

Returns the string representation of an SQL statement.

open override fun prepareSQL(builder: QueryBuilder): String

Returns the string representation of an SQL query, generated by appending SQL expressions to a QueryBuilder.

spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<ResultRow>
union
Link copied to clipboard
fun AbstractQuery<*>.union(other: Query): Union

Combines all results from this query with the results of other, WITHOUT including duplicates.

unionAll
Link copied to clipboard
fun AbstractQuery<*>.unionAll(other: Query): UnionAll

Combines all results from this query with the results of other, WITH duplicates included.

withDistinct
Link copied to clipboard
open override fun withDistinct(value: Boolean): SetOperation

Modifies this query to retrieve only distinct results if value is set to `true`.