我们如何在MySQL WHERE子句中使用CHAR_LENGTH()函数?
当CHAR_LENGTH()或CHARACTER_LENGTH()字符串函数与WHERE子句一起使用时,其返回的输出将取决于WHERE子句中给出的条件。例如,假设我们有一个名为“ Student”的表,并且只想获取字符数少于6的那些名称,那么我们可以编写以下查询-
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, CHAR_LENGTH(Name) from student WHERE CHAR_LENGTH(Name)<6;
+-------+-------------------+
| Name | CHAR_LENGTH(Name) |
+-------+-------------------+
| Aarav | 5 |
+-------+-------------------+
1 row in set (0.00 sec)
以上是 我们如何在MySQL WHERE子句中使用CHAR_LENGTH()函数? 的全部内容, 来源链接: utcz.com/z/334847.html