concat函数Graph
concat()
和concat_ws()
函数返回一个或多个字符串连接产生的字符串。
concat()函数Graph
concat()
函数至少需要两个或以上字符串参数,并将所有参数连接成一个字符串。
- 如果字符串参数只有一个,则返回该字符串参数本身。
- 如果任何一个的字符串参数为
NULL
,则concat()
函数返回值为NULL
。
语法Graph
concat(string1,string2,...)
示例Graph
//连接1,2,3
nebula> RETURN concat("1","2","3") AS r;
+-------+
| r |
+-------+
| "123" |
+-------+
//字符串参数有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()函数Graph
concat_ws()
函数将两个或以上字符串参数与预定义的分隔符(separator)相连接。
- 如果分隔符为
NULL
时,concat_ws()
函数才返回NULL
。
- 如果分隔符不为
NULL
,字符串参数只有一个,则返回该字符串参数本身。
- 字符串参数存在
NULL
值时,忽略NULL
值,继续连接下一个参数。
语法Graph
concat_ws(separator,string1,string2,... )
示例Graph
//分隔符为+,连接a,b,c
nebula> RETURN concat_ws("+","a","b","c") AS r;
+---------+
| r |
+---------+
| "a+b+c" |
+---------+
//分隔符为 NULL
neubla> RETURN concat_ws(NULL,"a","b","c") AS r;
+----------+
| r |
+----------+
| __NULL__ |
+----------+
//分隔符为+,字符串参数有NULL
nebula> RETURN concat_ws("+","a",NULL,"b","c") AS r;
+---------+
| r |
+---------+
| "a+b+c" |
+---------+
//分隔符为+。字符串参数只有一个
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" |
+---------------------------------+
最后更新: October 27, 2021