trait Select[Q, R] extends Renderable with Aggregatable[Q] with Joinable[Q, R] with JoinOps[Select, Q, R] with Query[Seq[R]] with DelegateQueryable[Q, Seq[R]] with Wrapped
A SQL SELECT
query, possible with JOIN
, WHERE
, GROUP BY
,
ORDER BY
, LIMIT
, OFFSET
clauses
Models the various components of a SQL SELECT:
SELECT DISTINCT column, AGG_FUNC(column_or_expression), … FROM mytable JOIN another_table ON mytable.column = another_table.column WHERE constraint_expression GROUP BY column HAVING constraint_expression ORDER BY column ASC/DESC LIMIT count OFFSET COUNT;
Good syntax reference:
https://www.cockroachlabs.com/docs/stable/selection-queries#set-operations https://www.postgresql.org/docs/current/sql-select.html
- Alphabetic
- By Inheritance
- Select
- Wrapped
- DelegateQueryable
- Query
- JoinOps
- Joinable
- Aggregatable
- WithSqlExpr
- Renderable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def aggregate[E, V](f: (Proxy[Q]) => E)(implicit qr: Row[E, V]): Aggregate[E, V]
Performs one or more aggregates in a single Select
- abstract def aggregateExpr[V](f: (Q) => (Context) => SqlStr)(implicit arg0: TypeMapper[V], qr: Row[Expr[V], V]): Expr[V]
- Definition Classes
- Aggregatable
- abstract def asc: Select[Q, R]
Combined with sortBy to make the sort order ascending, translates into SQL
ASC
- abstract def compound0(op: String, other: Select[Q, R]): CompoundSelect[Q, R]
- Attributes
- protected
- abstract def desc: Select[Q, R]
Combined with sortBy to make the sort order descending, translates into SQL
DESC
- abstract def dialect: DialectTypeMappers
- Attributes
- protected
- abstract def drop(n: Int): Select[Q, R]
Drops the first n rows from this Select.
Drops the first n rows from this Select. Like when used in Scala collections, if called multiple times the dropped rows add up
- abstract def expr: Q
- Attributes
- protected
- Definition Classes
- WithSqlExpr
- abstract def filter(f: (Q) => Expr[Boolean]): Select[Q, R]
Filters this Select with the given predicate, translates into a SQL
WHERE
clause - abstract def filterIf(cond: Boolean)(f: (Q) => Expr[Boolean]): Select[Q, R]
Filters this Select with the given predicate, if cond evaluates to true
- abstract def filterOpt[T](option: Option[T])(f: (Q, T) => Expr[Boolean]): Select[Q, R]
Filters this Select with the given predicate consuming provided option as a part of predicate's input, if this option is Some[T]
- abstract def flatMap[Q2, R2](f: (Q) => Rhs[Q2, R2])(implicit qr: Row[Q2, R2]): Select[Q2, R2]
Performs an implicit
JOIN
between this Select and the one returned by the callback function f - abstract def groupBy[K, V, R2, R3](groupKey: (Q) => K)(groupAggregate: (Proxy[Q]) => V)(implicit qrk: Row[K, R2], qrv: Row[V, R3]): Select[(K, V), (R2, R3)]
Translates into a SQL
GROUP BY
, takes a function specifying the group-key and a function specifying the group-aggregate. - abstract def join0[Q2, R2, QF, RF](prefix: String, other: Joinable[Q2, R2], on: Option[(Q, Q2) => Expr[Boolean]])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]
- Attributes
- protected
- Definition Classes
- JoinOps
- abstract def leftJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(Q, JoinNullable[Q2]), (R, Option[R2])]
Performs a
LEFT JOIN
on the given other, typically a Table or Select. - abstract def map[Q2, R2](f: (Q) => Q2)(implicit qr: Row[Q2, R2]): Select[Q2, R2]
Transforms the return value of this Select with the given function
- abstract def mapAggregate[Q2, R2](f: (Q, Proxy[Q]) => Q2)(implicit qr: Row[Q2, R2]): Select[Q2, R2]
Performs a
.map
which additionally provides a Aggregatable.Proxy that allows you to perform aggregate functions. - abstract def nullsFirst: Select[Q, R]
Combined with sortBy to configure handling of nulls, translates into SQL
NULLS FIRST
- abstract def nullsLast: Select[Q, R]
Combined with sortBy to configure handling of nulls, translates into SQL
NULLS LAST
- abstract def outerJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(JoinNullable[Q], JoinNullable[Q2]), (Option[R], Option[R2])]
Performs a
OUTER JOIN
on the given other, typically a Table or Select. - abstract def qr: Row[Q, R]
- Definition Classes
- Select → DelegateQueryable
- abstract def queryConstruct(args: ResultSetIterator): Seq[R]
- Attributes
- protected
- Definition Classes
- Query
- abstract def rightJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(JoinNullable[Q], Q2), (Option[R], R2)]
Performs a
RIGHT JOIN
on the given other, typically a Table or Select. - abstract def selectExprAliases(prevContext: Context): Seq[(Identity, SqlStr)]
- Attributes
- protected
- Definition Classes
- Wrapped
- abstract def selectRenderer(prevContext: Context): Renderer
- Attributes
- protected
- Definition Classes
- Wrapped
- abstract def selectToSimpleSelect(): SimpleSelect[Q, R]
- Attributes
- protected
- abstract def selectWithExprPrefix(preserveAll: Boolean, s: (Context) => SqlStr): Select[Q, R]
- Attributes
- protected
- abstract def selectWithExprSuffix(preserveAll: Boolean, s: (Context) => SqlStr): Select[Q, R]
- Attributes
- protected
- abstract def sortBy(f: (Q) => Expr[_]): Select[Q, R]
Sorts this Select via the given expression.
- abstract def take(n: Int): Select[Q, R]
Only returns the first n rows from this Select.
Only returns the first n rows from this Select. Like when used in Scala collections, if called multiple times only the smallest value of n takes effect
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def contains(other: Q): Expr[Boolean]
Returns whether or not the Select on the left contains the other value on the right
- def crossJoin[Q2, R2, QF, RF](other: Joinable[Q2, R2])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]
Performs a
CROSS JOIN
, which is anINNER JOIN
but without theON
clausePerforms a
CROSS JOIN
, which is anINNER JOIN
but without theON
clause- Definition Classes
- JoinOps
- def crossJoin[Q2, R2](): Mapper[Q, Q2, R, R2]
Version of
crossJoin
meant for usage infor
-comprehensionsVersion of
crossJoin
meant for usage infor
-comprehensions- Definition Classes
- Joinable
- def distinct: Select[Q, R]
Causes this Select to ignore duplicate rows, translates into SQL
SELECT DISTINCT
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def except(other: Select[Q, R]): Select[Q, R]
Subtracts the other from this Select, returning only rows present this but absent in other, and removing duplicates.
Subtracts the other from this Select, returning only rows present this but absent in other, and removing duplicates. Translates into SQL
EXCEPT
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def head: Single[R]
Shorthand for
.take(1).single
:Shorthand for
.take(1).single
:1. If the query returns a single row, this returns it as a single value of type R 2. If the query returns multiple rows, returns the first as a single value of type R and discards the rest 3. If the query returns zero rows, throws an exception.
- def intersect(other: Select[Q, R]): Select[Q, R]
Intersects the result rows of this Select with another, preserving only rows present in both this and the other and removing duplicates.
Intersects the result rows of this Select with another, preserving only rows present in both this and the other and removing duplicates. Translates into SQL
INTERSECT
- def isEmpty: Expr[Boolean]
Returns whether or not the Select on the left is empty with zero elements
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def join[Q2, R2, QF, RF](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]
Performs a
JOIN
/INNER JOIN
on the given other, typically a Table or Select. - def join[Q2, R2](on: (Q) => Expr[Boolean]): Mapper[Q, Q2, R, R2]
Version of
join
meant for usage infor
-comprehensionsVersion of
join
meant for usage infor
-comprehensions- Definition Classes
- Joinable
- def joinInfo[Q2, R2](joinPrefix: String, other: Joinable[Q2, R2], on: Option[(Q, Q2) => Expr[Boolean]]): (Seq[Join], Q2)
- Attributes
- protected
- Definition Classes
- JoinOps
- def joinableToFromExpr: (From, Q)
- def leftJoin[Q2, R2](on: (Q) => Expr[Boolean]): NullableMapper[Q, Q2, R, R2]
Version of
leftJoin
meant for usage infor
-comprehensionsVersion of
leftJoin
meant for usage infor
-comprehensions- Definition Classes
- Joinable
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def newCompoundSelect[Q, R](lhs: SimpleSelect[Q, R], compoundOps: Seq[Op[Q, R]], orderBy: Seq[OrderBy], limit: Option[Int], offset: Option[Int])(implicit qr: Row[Q, R], dialect: DialectTypeMappers): CompoundSelect[Q, R]
- Attributes
- protected
- def newSimpleSelect[Q, R](expr: Q, exprPrefix: Option[(Context) => SqlStr], exprSuffix: Option[(Context) => SqlStr], preserveAll: Boolean, from: Seq[From], joins: Seq[Join], where: Seq[Expr[_]], groupBy0: Option[GroupBy])(implicit qr: Row[Q, R], dialect: DialectTypeMappers): SimpleSelect[Q, R]
- Attributes
- protected
- def nonEmpty: Expr[Boolean]
Returns whether or not the Select on the left is nonempty with one or more elements
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def queryGetGeneratedKeys: Option[Row[_, _]]
- Attributes
- protected
- Definition Classes
- Query
- def queryIsExecuteUpdate: Boolean
- Attributes
- protected
- Definition Classes
- DelegateQueryable → Query
- def queryIsSingleRow: Boolean
- Attributes
- protected
- Definition Classes
- Select → DelegateQueryable → Query
- def queryWalkExprs(): Seq[Expr[_]]
- Attributes
- protected
- Definition Classes
- DelegateQueryable → Query
- def queryWalkLabels(): Seq[List[String]]
- Attributes
- protected
- Definition Classes
- DelegateQueryable → Query
- def single: Single[R]
Asserts that this query returns exactly one row, and returns a single value of type R rather than a
Seq[R]
.Asserts that this query returns exactly one row, and returns a single value of type R rather than a
Seq[R]
. Throws an exception if zero or multiple rows are returned. - def subquery: SimpleSelect[Q, R]
Forces this Select to be treated as a subquery that any further operations will operate on, rather than having some operations flattened out into clauses in this Select
- def subqueryRef(implicit qr: Row[Q, R]): SubqueryRef
- Attributes
- protected
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toExpr(implicit mt: TypeMapper[R]): Expr[R]
Converts this Select into an Expr, assuming it returns a single row and a single column.
Converts this Select into an Expr, assuming it returns a single row and a single column. Note that if this returns multiple rows, behavior is database-specific, with some like Sqlite simply taking the first row while others like Postgres/MySql throwing exceptions
- def toString(): String
- Definition Classes
- AnyRef → Any
- def union(other: Select[Q, R]): Select[Q, R]
Concatenates the result rows of this Select with another and removes duplicate rows; translates into SQL
UNION
- def unionAll(other: Select[Q, R]): Select[Q, R]
Concatenates the result rows of this Select with another; translates into SQL
UNION ALL
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withFilter(f: (Q) => Expr[Boolean]): Select[Q, R]
Alias for filter
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)