max(length(field)) in mysql

前端 未结 9 580
南方客
南方客 2021-01-30 06:25

If I say:

select max(length(Name)) 
  from my_table

I get the result as 18, but I want the concerned data also. So if I say:

s         


        
9条回答
  •  温柔的废话
    2021-01-30 06:38

    Use CHAR_LENGTH() instead-of LENGTH() as suggested in: MySQL - length() vs char_length()

    SELECT name, CHAR_LENGTH(name) AS mlen FROM mytable ORDER BY mlen DESC LIMIT 1

提交回复
热议问题