pub struct SelectQuery {Show 16 fields
pub with: With,
pub hints: Hints,
pub modifiers: Modifiers,
pub select_list: SelectList,
pub from: TableRef,
pub extra_from: Vec<TableRef>,
pub where_: Where,
pub group_by: GroupBy,
pub having: Having,
pub windows: Windows,
pub order_by: OrderBy,
pub limit: Limit,
pub offset: Offset,
pub locks: Locks,
pub lock_in_share_mode: bool,
pub combines: Combines,
}Expand description
A MySQL SELECT.
The field order is the clause order of https://dev.mysql.com/doc/refman/8.4/en/select.html:
[WITH [RECURSIVE] with_query [, ...]]
SELECT [hint_comment]
[ALL | DISTINCT | DISTINCTROW] [HIGH_PRIORITY] [STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr] ...
[FROM table_references]
[WHERE where_condition]
[GROUP BY {col_name | expr | position}, ... [WITH ROLLUP]]
[HAVING where_condition]
[WINDOW window_name AS (window_spec) [, ...]]
[ORDER BY {col_name | expr | position} [ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[FOR {UPDATE | SHARE} [OF tbl_name [, ...]] [NOWAIT | SKIP LOCKED]
| LOCK IN SHARE MODE]Two differences from PostgreSQL are worth stating.
The locking clause has two shapes, and they are alternatives. FOR UPDATE
and FOR SHARE are Locks; LOCK IN SHARE MODE is a production of its own
with no OF list and no wait option, so it is a flag rather than a
Lock strength. Setting both is a caller error
the server refuses.
LIMIT gates OFFSET. MySQL’s grammar spells the pair as one clause, so
OFFSET alone does not parse. Nothing here prevents it — the server is what
says no.
Fields§
§with: WithWITH ….
hints: Hints/*+ … */.
modifiers: ModifiersDISTINCT, HIGH_PRIORITY, STRAIGHT_JOIN, …
select_list: SelectListThe projection. Empty renders *.
from: TableRefThe first FROM item, with its joins.
extra_from: Vec<TableRef>Further comma-separated FROM items.
where_: WhereWHERE ….
group_by: GroupByGROUP BY … [WITH ROLLUP].
having: HavingHAVING ….
windows: WindowsWINDOW ….
order_by: OrderByORDER BY … — this query’s own.
limit: LimitLIMIT … — this query’s own.
offset: OffsetOFFSET … — this query’s own. Needs a LIMIT to be legal.
locks: LocksFOR UPDATE … / FOR SHARE ….
LOCK IN SHARE MODE, the pre-8.0 spelling of FOR SHARE.
combines: CombinesThe set operations, and the trailing clauses that belong to their result.
Implementations§
Source§impl SelectQuery
impl SelectQuery
Sourcepub fn new() -> SelectQuery
pub fn new() -> SelectQuery
An empty SELECT, which renders SELECT *.
Sourcepub fn apply(&mut self, mods: impl Mod<SelectQuery>)
pub fn apply(&mut self, mods: impl Mod<SelectQuery>)
Apply more mods to an existing query.
Trait Implementations§
Source§impl Clone for SelectQuery
impl Clone for SelectQuery
Source§fn clone(&self) -> SelectQuery
fn clone(&self) -> SelectQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SelectQuery
impl Debug for SelectQuery
Source§impl Default for SelectQuery
impl Default for SelectQuery
Source§fn default() -> SelectQuery
fn default() -> SelectQuery
Source§impl Expression for SelectQuery
impl Expression for SelectQuery
Source§impl HasCombines for SelectQuery
impl HasCombines for SelectQuery
Source§fn combines_mut(&mut self) -> &mut Combines
fn combines_mut(&mut self) -> &mut Combines
Source§impl HasExtraTables for SelectQuery
impl HasExtraTables for SelectQuery
Source§fn extra_tables_mut(&mut self) -> &mut Vec<TableRef>
fn extra_tables_mut(&mut self) -> &mut Vec<TableRef>
Source§impl HasGroupBy for SelectQuery
impl HasGroupBy for SelectQuery
Source§fn group_by_mut(&mut self) -> &mut GroupBy
fn group_by_mut(&mut self) -> &mut GroupBy
GROUP BY clause to modify.Source§impl HasHaving for SelectQuery
impl HasHaving for SelectQuery
Source§fn having_mut(&mut self) -> &mut Having
fn having_mut(&mut self) -> &mut Having
HAVING clause to modify.Source§impl HasHints for SelectQuery
impl HasHints for SelectQuery
Source§impl HasJoins for SelectQuery
impl HasJoins for SelectQuery
Source§impl HasLimit for SelectQuery
impl HasLimit for SelectQuery
Source§impl HasLocks for SelectQuery
impl HasLocks for SelectQuery
Source§impl HasModifiers for SelectQuery
impl HasModifiers for SelectQuery
Source§fn modifiers_mut(&mut self) -> &mut Modifiers
fn modifiers_mut(&mut self) -> &mut Modifiers
Source§impl HasOffset for SelectQuery
impl HasOffset for SelectQuery
Source§fn offset_mut(&mut self) -> &mut Offset
fn offset_mut(&mut self) -> &mut Offset
OFFSET clause to modify.Source§impl HasOrderBy for SelectQuery
impl HasOrderBy for SelectQuery
Source§fn order_by_mut(&mut self) -> &mut OrderBy
fn order_by_mut(&mut self) -> &mut OrderBy
ORDER BY clause to modify.Source§impl HasSelectList for SelectQuery
impl HasSelectList for SelectQuery
Source§fn select_list_mut(&mut self) -> &mut SelectList
fn select_list_mut(&mut self) -> &mut SelectList
Source§impl HasTableRef for SelectQuery
impl HasTableRef for SelectQuery
Source§fn table_ref_mut(&mut self) -> &mut TableRef
fn table_ref_mut(&mut self) -> &mut TableRef
Source§impl HasWhere for SelectQuery
impl HasWhere for SelectQuery
Source§impl HasWindows for SelectQuery
impl HasWindows for SelectQuery
Source§fn windows_mut(&mut self) -> &mut Windows
fn windows_mut(&mut self) -> &mut Windows
WINDOW clause to modify.