max(length(field)) in mysql

前端 未结 9 574
南方客
南方客 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:54

    I suppose you could use a solution such as this one :

    select name, length(name)
    from users
    where id = (
        select id
        from users
        order by length(name) desc
        limit 1
    );
    

    Might not be the optimal solution, though... But seems to work.

提交回复
热议问题