pub struct SelectBuilder { /* private fields */ }Expand description
Fluent builder for SELECT statements.
§Examples
use sqlglot_rust::builder::select;
let query = select(&["a", "b"])
.from("users")
.where_clause("active = true")
.order_by(&["created_at DESC"])
.limit(10)
.build();Implementations§
Source§impl SelectBuilder
impl SelectBuilder
Sourcepub fn columns(self, cols: &[&str]) -> Self
pub fn columns(self, cols: &[&str]) -> Self
Add columns to the SELECT list from strings.
Each string is parsed as an expression.
Sourcepub fn column_expr(self, expr: Expr, alias: Option<&str>) -> Self
pub fn column_expr(self, expr: Expr, alias: Option<&str>) -> Self
Add a single column expression.
Sourcepub fn all_from(self, table: &str) -> Self
pub fn all_from(self, table: &str) -> Self
Add a qualified wildcard (table.*) to the SELECT list.
Sourcepub fn from_table(self, table_ref: TableRef) -> Self
pub fn from_table(self, table_ref: TableRef) -> Self
Set the FROM clause to a table reference.
Sourcepub fn from_subquery(self, query: Statement, alias: &str) -> Self
pub fn from_subquery(self, query: Statement, alias: &str) -> Self
Set the FROM clause to a subquery.
Sourcepub fn right_join(self, table_name: &str, on: &str) -> Self
pub fn right_join(self, table_name: &str, on: &str) -> Self
Add a RIGHT JOIN clause.
Sourcepub fn cross_join(self, table_name: &str) -> Self
pub fn cross_join(self, table_name: &str) -> Self
Add a CROSS JOIN clause.
Sourcepub fn join_using(
self,
table_name: &str,
columns: &[&str],
join_type: JoinType,
) -> Self
pub fn join_using( self, table_name: &str, columns: &[&str], join_type: JoinType, ) -> Self
Add a JOIN with USING clause.
Sourcepub fn join_subquery(
self,
query: Statement,
alias: &str,
on: &str,
join_type: JoinType,
) -> Self
pub fn join_subquery( self, query: Statement, alias: &str, on: &str, join_type: JoinType, ) -> Self
Add a JOIN with a subquery.
Sourcepub fn where_clause(self, condition: &str) -> Self
pub fn where_clause(self, condition: &str) -> Self
Set the WHERE clause from a string.
Sourcepub fn where_expr(self, expr: Expr) -> Self
pub fn where_expr(self, expr: Expr) -> Self
Set the WHERE clause from an expression.
Sourcepub fn add_group_by(self, expr: &str) -> Self
pub fn add_group_by(self, expr: &str) -> Self
Add a GROUP BY expression.
Sourcepub fn add_order_by(self, expr: &str) -> Self
pub fn add_order_by(self, expr: &str) -> Self
Add an ORDER BY item.
Sourcepub fn add_order_by_expr(
self,
expr: Expr,
ascending: bool,
nulls_first: Option<bool>,
) -> Self
pub fn add_order_by_expr( self, expr: Expr, ascending: bool, nulls_first: Option<bool>, ) -> Self
Add an ORDER BY item with explicit direction.
Sourcepub fn limit_expr(self, expr: Expr) -> Self
pub fn limit_expr(self, expr: Expr) -> Self
Set the LIMIT clause from an expression.
Sourcepub fn offset_expr(self, expr: Expr) -> Self
pub fn offset_expr(self, expr: Expr) -> Self
Set the OFFSET clause from an expression.
Sourcepub fn build_select(self) -> SelectStatement
pub fn build_select(self) -> SelectStatement
Build and return the inner SelectStatement.
Trait Implementations§
Source§impl Clone for SelectBuilder
impl Clone for SelectBuilder
Source§fn clone(&self) -> SelectBuilder
fn clone(&self) -> SelectBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SelectBuilder
impl Debug for SelectBuilder
Auto Trait Implementations§
impl Freeze for SelectBuilder
impl RefUnwindSafe for SelectBuilder
impl Send for SelectBuilder
impl Sync for SelectBuilder
impl Unpin for SelectBuilder
impl UnsafeUnpin for SelectBuilder
impl UnwindSafe for SelectBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more