APPEND_TRAILING_CHAR_IF_ABSENT
Descriptionβ
Used to add a specific character (such as a space, a specific symbol, etc.) to the end of a string if the character does not exist at the end of the string. The function is to ensure that the string ends with a specific character.
Syntaxβ
APPEND_TRAILING_CHAR_IF_ABSENT ( <str> , <trailing_char> )
Parametersβ
Parameters | Description |
---|---|
<str> | Target string to be judged |
<trailing_char> | Character to be added to the end of the string (if the character does not exist) |
Return valueβ
Parameters The string after concatenation of <str>
and <trailing_char>
(if <trailing_char>
does not exist in <str>
)
Exampleβ
SELECT APPEND_TRAILING_CHAR_IF_ABSENT('a','c'),APPEND_TRAILING_CHAR_IF_ABSENT('ac', 'c'),APPEND_TRAILING_CHAR_IF_ABSENT('ac', 'cd')
+------------------------------------------+-------------------------------------------+--------------------------------------------+
| append_trailing_char_if_absent('a', 'c') | append_trailing_char_if_absent('ac', 'c') | append_trailing_char_if_absent('ac', 'cd') |
+------------------------------------------+-------------------------------------------+--------------------------------------------+
| ac | ac | accd |
+------------------------------------------+-------------------------------------------+--------------------------------------------+