[Solved] How to write Nested query in MySQL? [closed]


SELECT a.*
 FROM ( 
     select City, length( City )
     from Station
     where length( City ) = ( select max( length( City ) ) from Station )
     order by city
     limit 1 
   ) a
UNION ALL 
SELECT b.*
 FROM ( 
     select City, length( City )
     from Station
     where length( City ) = ( select min( length( City ) ) from Station )
     order by city
     limit 1
) b;

you can edit the max to min to get the min length of the city

I think if you want it in one query it will be more complex

sqlfiddle to test the query

4

solved How to write Nested query in MySQL? [closed]