Skip to content

Commit

Permalink
Update string-functions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
qiancai committed Nov 22, 2023
1 parent a21eaa1 commit 2203347
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,49 @@ For comparisons between functions and syntax of Oracle and TiDB, see [Comparison

## Supported functions

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

Return numeric value of left-most character.
The `ASCII(str)` function is used to get the ASCII value of the leftmost character in a given string (`str`).

- If `str` is not empty, the function returns the ASCII value of the leftmost character.
- If `str` is an empty string, the function returns 0.
- If `str` is `NULL`, the function returns `NULL`.

> **Note:**
>
> ASCII() only works for characters represented using 8 bits of binary digits (one byte).
Examples:

```sql
SELECT ASCII('A');

+------------+
| ASCII('A') |
+------------+
| 65 |
+------------+
```

```sql
SELECT ASCII('');

+------------+
| ASCII('') |
+------------+
| 0 |
+------------+
```

```sql
SELECT ASCII('TiDB');

+------------+
| ASCII('T') |
+------------+
| 84 |
+------------+
```

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

Expand Down

0 comments on commit 2203347

Please sign in to comment.