将 ASCII() 函数与 WHERE 子句一起使用时,其返回的输出将取决于 WHERE 子句中给出的条件。例如,假设我们有一个名为“学生”的表,我们想要获取学生姓名的第一个字符的大于 65 的数字代码。对此的查询可以写成如下 -
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)
登录后复制
以上就是我们如何将 ASCII() 函数与 MySQL WHERE 子句一起使用?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!