I have a table with one of the columns is of type varchar(city). and want to find the longest and shortest of values stored in that column.
select a.city, a.city
For shortest name of city :
SELECT ST.CITY,LENGTH(ST.CITY) AS LENGTH FROM STATION ST ORDER BY LENGTH ASC, ST.CITY ASC LIMIT 1;
For longest name of city :
SELECT ST.CITY,LENGTH(ST.CITY) AS LENGTH FROM STATION ST ORDER BY LENGTH DESC, ST.CITY DESC LIMIT 1;