sql query longest record a field

  Sql query text length field value of the longest record 

A function
. 1, the SQL Server
LEN () function returns the value of the length of the text field.
LEN the SELECT (column_name) the FROM table_name;
2, the MySQL
the LENGTH () function returns the value of the length of the text field.
SELECT LENGTH (column_name) FROM table_name;

Second, the simple use of
1, SQL Server
the SELECT
`field`, len ( `field`)
from table name
the WHERE
len (field ``) = (select max (len ( ` field`)) from table name)

2, the MySQL
SELECT
`field`, length ( `` field)
from the table name
WHERE
length (field ``) = (select max (length ( ` field`)) from table)

Reference document:
http://www.cnblogs.com/lxcmyf/p/7146683.html
https://blog.csdn.net/weixin_34112030/article/details/85941064

 

Guess you like

Origin www.cnblogs.com/hao-1234-1234/p/11465143.html