Select*fromstudent;+------+---------+---------+-------- ---+|Id |Name |Address|Subject |+------+---"/> Select*fromstudent;+------+---------+---------+-------- ---+|Id |Name |Address|Subject |+------+---">
Home >Database >Mysql Tutorial >How can we use ASCII() function with MySQL WHERE clause?
When you use the ASCII() function with a WHERE clause, the output it returns will depend on the conditions given in the WHERE clause. For example, let's say we have a table called "Students" and we want to get the numeric code greater than 65 for the first character of a student's name. A query for this can be written as follows -
mysql> Select * from student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 20 | Gaurav | Jaipur | Computers | +------+---------+---------+-----------+ 4 rows in set (0.10 sec) mysql> Select Name, ASCII(Name) As 'ASCII VALUE OF 1st Character' From Student WHERE ASCII(Name)>65; +---------+------------------------------+ | Name | ASCII VALUE OF 1st Character | +---------+------------------------------+ | Gaurav | 71 | | Harshit | 72 | | Gaurav | 71 | +---------+------------------------------+ 3 rows in set (0.00 sec)
The above is the detailed content of How can we use ASCII() function with MySQL WHERE clause?. For more information, please follow other related articles on the PHP Chinese website!