Home > Database > Mysql Tutorial > body text

How can we use ASCII() function with MySQL WHERE clause?

WBOY
Release: 2023-08-25 21:09:02
forward
729 people have browsed it

我们如何将 ASCII() 函数与 MySQL WHERE 子句一起使用?

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!