Hi all, i have a table like below

Id Names

1 Sanjay, Anu, Rock
2 Mohamed, Asif, Selva, Manoj, Booker T
3 Jerrico, Cena
4 Amala

How do i select MAX LENGTH OF STRING from column in the table,

I need the result like,

2 Mohamed, Asif, Selva, Manoj, Booker T

Is there any query for that ??

Member Avatar

diafol

"SELECT id, CHAR_LENGTH(`Names`) AS maxlength ORDER BY maxlength DESC"

Hi Ardav, Thank your for reply, i applied your code it gives me an empty value. Any idea?

Member Avatar

diafol

Doh i forgot to put a table in the sql. Put

From table

After as maxlength where table is your tablename

Member Avatar

diafol

Like?

SELECT id, CHAR_LENGTH(`Names`) AS maxlength FROM table

Should be the bare minimum to display id, maxlength

SELECT id, CHAR_LENGTH(`Names`) AS maxlength FROM table ORDER BY maxlength DESC, `Names` LIMIT 1

Will get you the record with longest names field

Hi Ardav Thank you for reply. Its worked for me thank u, but little change DESC to ASC. Thank You. I Marked the thread as closed.