- 카테고리:
문자열 및 이진 함수 (일반)
CONCAT_WS¶
Concatenates two or more strings, or concatenates two or more binary values, and uses the first argument as a delimiter between the following strings.
참고
CONCAT_WS 함수의 일부 구현과 달리, Snowflake CONCAT_WS 함수는 NULL 값을 건너뛰지 않습니다.
- 참고 항목:
구문¶
CONCAT_WS( <separator> , <expression> [ , <expression> ... ] )
인자¶
separatorThe separator must meet the same requirements as
expression.expressionThe input expressions must be all strings, or all binary values.
반환¶
The function returns a VARCHAR or BINARY value that contains the 2nd through Nth arguments, separated by the first argument.
인자 중 하나라도 NULL이면 이 함수는 NULL을 반환합니다.
The data type of the returned value is the same as the data type of the input values.
사용법 노트¶
GET_DDL 같은 메타데이터 함수는 상수만 입력으로 받아들입니다. 연결된 입력은 오류를 생성합니다.
CONCAT_WS는 마지막 인자 뒤가 아니라 인자 사이에 구분 기호를 넣습니다. 구분 기호 뒤에 하나의 인자만 사용하여 CONCAT_WS를 호출하는 경우, 구분 기호가 추가되지 않습니다.
데이터 정렬 세부 정보¶
The collation specifications of all input arguments must be compatible.
The collation of the result of the function is the highest-precedence collation of the inputs.
예¶
Call the CONCAT_WS function to concatenate three strings with a comma separator:
SELECT CONCAT_WS(',', 'one', 'two', 'three');
+---------------------------------------+
| CONCAT_WS(',', 'ONE', 'TWO', 'THREE') |
|---------------------------------------|
| one,two,three |
+---------------------------------------+
다음 예제에서 인자가 NULL인 경우 함수는 NULL을 반환합니다.
SELECT CONCAT_WS(',', 'one', NULL, 'two');
+------------------------------------+
| CONCAT_WS(',', 'ONE', NULL, 'TWO') |
|------------------------------------|
| NULL |
+------------------------------------+
The following example shows that when there is only one string to concatenate, the CONCAT_WS function doesn’t append a separator:
SELECT CONCAT_WS(',', 'one');
+-----------------------+
| CONCAT_WS(',', 'ONE') |
|-----------------------|
| one |
+-----------------------+