pub struct Select { /* private fields */ }
Expand description
Represents the creation of a SELECT with specified table and options.
Implementations§
Source§impl Select
impl Select
Sourcepub fn new(table: &str) -> Self
pub fn new(table: &str) -> Self
Creates a new Select
instance with the specified table name.
§Example
use lumus_sql_builder::sqlite::Select;
let select = Select::new("users").columns("name, age").build().unwrap();
assert_eq!(select, "SELECT name, age FROM users;")
Sourcepub fn from(query: &str) -> Result<Select, SqlBuilderError>
pub fn from(query: &str) -> Result<Select, SqlBuilderError>
Creates a new Select
instance from a SQL query string.
The query string should be in the format “SELECT * FROM table_name [WHERE condition] [GROUP BY column] [ORDER BY column] [LIMIT limit] [OFFSET offset]”.
§Example
use lumus_sql_builder::sqlite::Select;
let query = "SELECT * FROM users WHERE age > 18 GROUP BY city ORDER BY name LIMIT 10 OFFSET 0";
Select::from(query);
Sourcepub fn distinct(&mut self) -> &mut Self
pub fn distinct(&mut self) -> &mut Self
Specifies that the select statement should return distinct rows.
Sourcepub fn columns(&mut self, columns: &str) -> &mut Self
pub fn columns(&mut self, columns: &str) -> &mut Self
Specifies the columns to be selected in the query.
Sourcepub fn group(&mut self, group: &str) -> &mut Self
pub fn group(&mut self, group: &str) -> &mut Self
Specifies the grouping for the query results.
Sourcepub fn order(&mut self, order: &str) -> &mut Self
pub fn order(&mut self, order: &str) -> &mut Self
Specifies the ordering for the query results.
Sourcepub fn limit(&mut self, limit: u32) -> &mut Self
pub fn limit(&mut self, limit: u32) -> &mut Self
Specifies the maximum number of rows to be returned by the query.
Sourcepub fn build(&self) -> Result<String, SqlBuilderError>
pub fn build(&self) -> Result<String, SqlBuilderError>
Builds and returns the SQL statement for the select query.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Select
impl RefUnwindSafe for Select
impl Send for Select
impl Sync for Select
impl Unpin for Select
impl UnwindSafe for Select
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