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>where
V: SQLParam + 'a,
V::DialectMarker: PostgresStringSupport,
E: Expr<'a, V>,
E::SQLType: Textual,
D: Expr<'a, V>,
D::SQLType: Textual,
D::Aggregate: AggregateKind,
N: Expr<'a, V>,
N::SQLType: Integral,
N::Aggregate: AggregateKind,
E::Aggregate: AggOr<D::Aggregate>,
<E::Aggregate as AggOr<D::Aggregate>>::Output: AggOr<N::Aggregate>,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);