One, ASCII (STR1)
Returns the ASCII code value of the leftmost character of the string str. If Str is an empty string, returns 0. If STR is NULL, return null
Example:
1.
The code is as follows |
Copy Code |
Mysql> Select ASCII (' Hi '); + ————-+ | ASCII (' Hi ') | + ————-+ | 104 | + ————-+ 1 row in Set
|
104 is the ASCII value of H
2. ASCII values for output B and B
The code is as follows |
Copy Code |
Mysql> SELECT ASCII (' B ') as Lower_case, ASCII (' B ') as upper_case; + ———— + ———— + | Lower_case | Upper_case | + ———— + ———— + | 98 | 66 | + ———— + ———— + 1 row in Set |
3. Using the ASCII function in the WHERE statement
Output Aut_name The ASCII value of the first letter is less than 70 data
The code is as follows |
Copy Code |
SELECT Aut_name,ascii (Aut_name) as "ASCII value of 1st character" From author WHERE ASCII (aut_name) <70; |
4. There is no data in the output field that does not have an ASCII value
The code is as follows |
Copy Code |
SELECT * FROM table_name WHERE not Column_to_check REGEXP ' [a-za-z0-9.,-] '; |
5. Use a computed string with substring the second subsequent ASCII value
The code is as follows |
Copy Code |
Mysql> Select ASCII (SUBSTRING (' database ', 2, 1)); + ———————————-+ | ASCII (SUBSTRING (' database ', 2, 1)) | + ———————————-+ | 97 | + ———————————-+ 1 row in Set |
Second, Ord function
ORD (str)
If the string str leftmost character is a multibyte character, it is passed in a format
The code is as follows |
Copy Code |
((*256+ (second byte ASCII code)) [*256+third byte ASCII code ...] |
Returns the ASCII code value of the character to return the multibyte character code. If the leftmost character is not a multibyte character. Returns the same value returned with the ASCII () function.
code is as follows |
copy code |
1 MySQL > select ORD (' 2 '); 2 -> |