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 contain the @trailing_char character at the end, it appends the @trailing_char character to the end. @trailing_char contains only one character, and it will return NULL if contains more than one character

example

1. MySQL [test]> select append_trailing_char_if_absent('a','c');
2. +------------------------------------------+
3. | append_trailing_char_if_absent('a', 'c') |
4. +------------------------------------------+
5. | ac                                       |
6. +------------------------------------------+
7. 1 row in set (0.02 sec)

9. MySQL [test]> select append_trailing_char_if_absent('ac','c');
10. +-------------------------------------------+
11. | append_trailing_char_if_absent('ac', 'c') |
12. +-------------------------------------------+
13. | ac                                        |
14. +-------------------------------------------+
15. 1 row in set (0.00 sec)

keywords

1. APPEND_TRAILING_CHAR_IF_ABSENT