VeloDB Cloud
SQL Manual
Functions
string-functions
append_trailing_char_if_absent

append_trailing_char_if_absent

Description

Syntax:

VARCHAR append_trailing_char_if_absent(VARCHAR str, VARCHAR trailing_char)

If the str string is non-empty and does not end with the trailing_char character, this function will append trailing_char to the end of str. trailing_char should contain only one character. If it contains more than one character, the function will return NULL.

Example

MySQL [test]> select append_trailing_char_if_absent('a','c');
+------------------------------------------+
| append_trailing_char_if_absent('a', 'c') |
+------------------------------------------+
| ac                                       |
+------------------------------------------+
1 row in set (0.02 sec)

MySQL [test]> select append_trailing_char_if_absent('ac','c');
+-------------------------------------------+
| append_trailing_char_if_absent('ac', 'c') |
+-------------------------------------------+
| ac                                        |
+-------------------------------------------+
1 row in set (0.00 sec)

Keywords

APPEND_TRAILING_CHAR_IF_ABSENT