> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# append_trailing_char_if_absent

> 如果字符串非空且末尾不包含指定字符，则将该字符附加到末尾。

如果 str 字符串非空并且末尾不包含 trailing\_char 字符，则将 trailing\_char 字符附加到末尾。

## 语法

```Haskell theme={null}
append_trailing_char_if_absent(str, trailing_char)
```

## 参数说明

`str`: 给定字符串，支持的数据类型为 VARCHAR。

`trailing_char`: 给定字符，支持的数据类型为 VARCHAR，trailing\_char 只能包含一个字符，若包含多个字符，将返回 NULL。

## 返回值说明

返回值的数据类型为 VARCHAR。

## 示例

```Plain Text theme={null}
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)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.