Skip to main content

concat_ws

Function concat_ws 

Source
pub fn concat_ws<'a, V, S, I>(
    sep: S,
    values: I,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, S::Nullable, <S::Aggregate as AggOr<<I::Item as Expr<'a, V>>::Aggregate>>::Output>
where V: SQLParam + 'a, S: Expr<'a, V>, S::SQLType: Textual, I: IntoIterator, I::Item: Expr<'a, V>, <I::Item as Expr<'a, V>>::SQLType: Textual, S::Aggregate: AggOr<<I::Item as Expr<'a, V>>::Aggregate>, <I::Item as Expr<'a, V>>::Aggregate: AggregateKind,
Expand description

CONCAT_WS - concatenates values with a separator, skipping NULLs.

Unlike ||, CONCAT_WS skips NULL values and never returns NULL (unless the separator itself is NULL).

Supported by both SQLite (3.44+) and PostgreSQL.

ยงExample

use drizzle_core::expr::concat_ws;

// SELECT CONCAT_WS(', ', users.city, users.state, users.country)
let location = concat_ws(", ", [users.city, users.state, users.country]);