SelectBuilder

Type Alias SelectBuilder 

Source
pub type SelectBuilder<'a, Schema, State, Table = ()> = QueryBuilder<'a, Schema, State, Table>;
Expand description

Builds a SELECT query specifically for PostgreSQL

Aliased Type§

pub struct SelectBuilder<'a, Schema, State, Table = ()> {
    pub sql: SQL<'a, PostgresValue<'a>>,
    /* private fields */
}

Fields§

§sql: SQL<'a, PostgresValue<'a>>

Implementations§

Source§

impl<'a, S> SelectBuilder<'a, S, SelectInitial>

Source

pub fn from<T>(self, query: T) -> SelectBuilder<'a, S, SelectFromSet, T>
where T: ToSQL<'a, PostgresValue<'a>>,

Specifies the table to select FROM and transitions state

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectFromSet, T>

Source

pub fn join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

Adds a JOIN clause to the query

Source

pub fn natural_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_left_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_left_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_right_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn right_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn right_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_right_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_full_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn full_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn full_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_full_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn inner_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn cross_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn left_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn inner_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn where( self, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectWhereSet, T>

Source

pub fn group_by( self, expressions: impl IntoIterator<Item = impl ToSQL<'a, PostgresValue<'a>>>, ) -> SelectBuilder<'a, S, SelectGroupSet, T>

Adds a GROUP BY clause to the query

Source

pub fn limit(self, limit: usize) -> SelectBuilder<'a, S, SelectLimitSet, T>

Limits the number of rows returned

Source

pub fn offset(self, offset: usize) -> SelectBuilder<'a, S, SelectOffsetSet, T>

Sets the offset for the query results

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Sorts the query results

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectJoinSet, T>

Source

pub fn where( self, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectWhereSet, T>

Adds a WHERE condition after a JOIN

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Sorts the query results

Source

pub fn join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

Adds a JOIN clause to the query

Source

pub fn natural_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_left_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_left_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_right_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn right_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn right_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_right_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_full_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn full_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn full_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn natural_full_outer_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn inner_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn cross_join<U: PostgresTable<'a>>( self, table: U, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with ON clause

Source

pub fn left_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn left_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn inner_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, T>

JOIN with USING clause (PostgreSQL-specific)

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectJoinSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectWhereSet, T>

Source

pub fn group_by( self, expressions: impl IntoIterator<Item = impl ToSQL<'a, PostgresValue<'a>>>, ) -> SelectBuilder<'a, S, SelectGroupSet, T>

Adds a GROUP BY clause after a WHERE

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Adds an ORDER BY clause after a WHERE

Source

pub fn limit(self, limit: usize) -> SelectBuilder<'a, S, SelectLimitSet, T>

Adds a LIMIT clause after a WHERE

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectWhereSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectGroupSet, T>

Source

pub fn having( self, condition: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectGroupSet, T>

Adds a HAVING clause after GROUP BY

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Adds an ORDER BY clause after GROUP BY

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectGroupSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectOrderSet, T>

Source

pub fn limit(self, limit: usize) -> SelectBuilder<'a, S, SelectLimitSet, T>

Adds a LIMIT clause after ORDER BY

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectOrderSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectLimitSet, T>

Source

pub fn offset(self, offset: usize) -> SelectBuilder<'a, S, SelectOffsetSet, T>

Adds an OFFSET clause after LIMIT

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectLimitSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectOffsetSet, T>

Source

pub fn as_cte( self, name: &'static str, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased, Self>

Converts this SELECT query into a CTE (Common Table Expression) with the given name.

Source§

impl<'a, S, State, T> SelectBuilder<'a, S, State, T>
where State: ExecutableState,

Source

pub fn union( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using UNION.

Source

pub fn union_all( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using UNION ALL.

Source

pub fn intersect( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using INTERSECT.

Source

pub fn intersect_all( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using INTERSECT ALL.

Source

pub fn except( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using EXCEPT.

Source

pub fn except_all( self, other: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T>

Combines this query with another using EXCEPT ALL.

Source§

impl<'a, S, T> SelectBuilder<'a, S, SelectSetOpSet, T>

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Sorts the results of a set operation.

Source

pub fn limit(self, limit: usize) -> SelectBuilder<'a, S, SelectLimitSet, T>

Limits the results of a set operation.

Source

pub fn offset(self, offset: usize) -> SelectBuilder<'a, S, SelectOffsetSet, T>

Offsets the results of a set operation.