您好,欢迎访问一九零五行业门户网

如何使用 MySQL OCTET_LENGTH() 函数来计算数据列中存储的字符数?

我们需要将列名作为 octet_length() 函数的参数传递,以计算数据列中存储的字符数。它显示在 select 子句中引用时的字符数。它还可以用作比较值,通过在 where 子句中使用它来决定是否应返回该行。 ‘student’表的内容用于演示 -
mysql> select name, octet_length(name)as 'str_length' from student;+---------+------------+| name | str_length |+---------+------------+| gaurav | 6 || aarav | 5 || harshit | 7 || gaurav | 6 || yashraj | 7 |+---------+------------+5 rows in set (0.00 sec)mysql> select name, octet_length(name)as 'str_length' from student where octet_length(name) < 7;+--------+------------+| name | str_length |+--------+------------+| gaurav | 6 || aarav | 5 || gaurav | 6 |+--------+------------+3 rows in set (0.06 sec)
以上就是如何使用 mysql octet_length() 函数来计算数据列中存储的字符数?的详细内容。
其它类似信息

推荐信息