Skip to main content

split_part

Function split_part 

Source
pub fn split_part<'a, V, E, D, N>(
    expr: E,
    delimiter: D,
    n: N,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, E::Nullable, <<E::Aggregate as AggOr<D::Aggregate>>::Output as AggOr<N::Aggregate>>::Output>
Expand description

SPLIT_PART - splits a string and returns the nth field (PostgreSQL).

Returns the field at position n (1-indexed) when splitting by delimiter.

ยงExample

use drizzle_core::expr::split_part;

// SELECT SPLIT_PART(users.email, '@', 2)  -- get domain
let domain = split_part(users.email, "@", 2);