Skip to main content

left

Function left 

Source
pub fn left<'a, V, E, N>(
    expr: E,
    n: N,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, <E::Nullable as Nullability>::Or<N::Nullable>, <E::Aggregate as AggregateKind>::Or<N::Aggregate>, (E::Sources, N::Sources)>
Expand description

The first n characters of a text value (LEFT), on PostgreSQL and MySQL.

expr must be text and n an integer. The result is text, nullable if either argument is. SQLite has no LEFT; use substr there.

ยงExamples

assert_eq!(left(users.name, 3).sql(), r#"LEFT ("users"."name", $1)"#);