+4 votes
in Databases by (60.0k points)
In my table, one VARCHAR column has strings of different sizes. How can I find the value that has the maximum length?

1 Answer

+1 vote
by (353k points)
selected by
Best answer

I have a table "videodb" and the column "title" is VARCHAR.

I can get the title with maximum length using one of the following SQLs.

Approach 1

SELECT  title, LENGTH(title) AS title_len
FROM    videodb
ORDER BY  title_len DESC LIMIT 1

Approach 2

SELECT  max(LENGTH(title)) AS title_len
FROM    videodb