max(length(field)) in mysql

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

    In case you need both max and min from same table:

        select * from (
    (select city, length(city) as maxlen from station
    order by maxlen desc limit 1)
    union
    (select city, length(city) as minlen from station
    order by minlen,city limit 1))a;
    

提交回复
热议问题