append_trailing_char_if_absent

description

Syntax

VARCHAR append_trailing_char_if_absent(VARCHAR str, VARCHAR trailing_char)

If the s string is non-empty and does not contain the c character at the end, it appends the c 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)
  8. MySQL [test]> select append_trailing_char_if_absent('ac','c');
  9. +-------------------------------------------+
  10. | append_trailing_char_if_absent('ac', 'c') |
  11. +-------------------------------------------+
  12. | ac |
  13. +-------------------------------------------+
  14. 1 row in set (0.00 sec)

keyword

APPEND_TRAILING_CHAR_IF_ABSENT