concat function¶
The concat() and concat_ws() functions return strings concatenated by one or more strings.
concat() function¶
The concat() function requires at least two or more strings. All the parameters are concatenated into one string.
- If there is only one string, the string itself is returned.
- If any one of the strings is
NULL,NULLis returned.
Syntax¶
bash
concat(string1,string2,...)
Examples¶
```bash //This example concatenates 1, 2, and 3. nebula> RETURN concat("1","2","3") AS r; +-------+ | r | +-------+ | "123" | +-------+
//In this example, one of the string is NULL. nebula> RETURN concat("1","2",NULL) AS r; +----------+ | r | +----------+ | NULL | +----------+
nebula> GO FROM "player100" over follow \ YIELD concat(src(edge), properties(\(^).age, properties(\)$).name, properties(edge).degree) AS A; +------------------------------+ | A | +------------------------------+ | "player10042Tony Parker95" | | "player10042Manu Ginobili95" | +------------------------------+ ```
concat_ws() function¶
The concat_ws() function connects two or more strings with a predefined separator.
- If the separator is
NULL, theconcat_ws()function returnsNULL.
- If the separator is not
NULLand there is only one string, the string itself is returned.
- If the separator is not
NULLand there is aNULLin the strings,NULLis ignored during the concatenation.
Syntax¶
bash
concat_ws(separator,string1,string2,... )
Examples¶
```bash //This example concatenates a, b, and c with the separator +. nebula> RETURN concat_ws("+","a","b","c") AS r; +---------+ | r | +---------+ | "a+b+c" | +---------+
//In this example, the separator is NULL. neubla> RETURN concat_ws(NULL,"a","b","c") AS r; +----------+ | r | +----------+ | NULL | +----------+
//In this example, the separator is + and there is a NULL in the strings. nebula> RETURN concat_ws("+","a",NULL,"b","c") AS r; +---------+ | r | +---------+ | "a+b+c" | +---------+
//In this example, the separator is + and there is only one string. nebula> RETURN concat_ws("+","a") AS r; +-----+ | r | +-----+ | "a" | +-----+
nebula> GO FROM "player100" over follow \ YIELD concat_ws(" ",src(edge), properties(\(^).age, properties(\)$).name, properties(edge).degree) AS A; +---------------------------------+ | A | +---------------------------------+ | "player100 42 Tony Parker 95" | | "player100 42 Manu Ginobili 95" | +---------------------------------+ ```