max(length(field)) in mysql

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

    select * 
    from my_table 
    where length( Name ) = ( 
          select max( length( Name ) ) 
          from my_table
          limit 1 
    );
    

    It this involves two table scans, and so might not be very fast !

提交回复
热议问题