Skip to content

Commit 2203347

Browse files
committed
Update string-functions.md
1 parent a21eaa1 commit 2203347

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

functions-and-operators/string-functions.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,49 @@ For comparisons between functions and syntax of Oracle and TiDB, see [Comparison
1616

1717
## Supported functions
1818

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

21-
Return numeric value of left-most character.
21+
The `ASCII(str)` function is used to get the ASCII value of the leftmost character in a given string (`str`).
22+
23+
- If `str` is not empty, the function returns the ASCII value of the leftmost character.
24+
- If `str` is an empty string, the function returns 0.
25+
- If `str` is `NULL`, the function returns `NULL`.
26+
27+
> **Note:**
28+
>
29+
> ASCII() only works for characters represented using 8 bits of binary digits (one byte).
30+
31+
Examples:
32+
33+
```sql
34+
SELECT ASCII('A');
35+
36+
+------------+
37+
| ASCII('A') |
38+
+------------+
39+
| 65 |
40+
+------------+
41+
```
42+
43+
```sql
44+
SELECT ASCII('');
45+
46+
+------------+
47+
| ASCII('') |
48+
+------------+
49+
| 0 |
50+
+------------+
51+
```
52+
53+
```sql
54+
SELECT ASCII('TiDB');
55+
56+
+------------+
57+
| ASCII('T') |
58+
+------------+
59+
| 84 |
60+
+------------+
61+
```
2262

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

0 commit comments

Comments
 (0)