max(length(field)) in mysql

mysql, sql

Solution

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

Problem

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: ``` select max(length(Name)), Name from my_table ``` ...it does not work. There should be a self join I guess which I am unable to figure it out. Can anyone please provide me a clue?

Original source

Related problems