Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions-and-operators: enrich instructions for string functions CHAR_LENGTH() and CHARACTER_LENGTH #15483 #16517

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,38 @@ SELECT BIN(-7);

### [`CHAR_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length)

返回字符串的字符长度
`CHAR_LENGTH()` 函数用于获取输入参数中字符的总数。

示例:

```sql
SELECT CHAR_LENGTH("TiDB") AS LengthOfString;

+----------------+
| LengthOfString |
+----------------+
| 4 |
+----------------+
```

```sql
SELECT CustomerName, CHAR_LENGTH(CustomerName) AS LenghtOfName FROM Customers;

+--------------------+--------------+
| CustomerName | LenghtOfName |
+--------------------+--------------+
| Albert Einstein | 15 |
| Robert Oppenheimer | 18 |
+--------------------+--------------+
```

> **注意:**
>
> 上面这个示例假设数据库中存在一个名为 `Customers` 的表,表中有一个名为 `CustomerName` 的列。

### [`CHARACTER_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_character-length)

`CHAR_LENGTH()` 功能相同
`CHARACTER_LENGTH()` 函数与 `CHAR_LENGTH()` 函数作用相同,返回结果相同,可以互换使用。
qiancai marked this conversation as resolved.
Show resolved Hide resolved

### [`CONCAT()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat)

Expand Down
Loading