You are viewing a single comment's thread. Return to all comments →
SELECT CITY, CHAR_LENGTH(CITY) FROM STATION ORDER BY CHAR_LENGTH(CITY), CITY LIMIT 1;
SELECT CITY, CHAR_LENGTH(CITY) FROM STATION ORDER BY CHAR_LENGTH(CITY) DESC, CITY LIMIT 1;
what does the LIMIT keyword do?
The LIMIT keyword limit the number of record as you expect
You can learn more here "https://www.w3schools.com/sql/default.asp"
Limit will help you to select only particular number of entries e.g. 1 in this case
suppose there are multiple cities with min length ( as it is in this case, 3 cities) , your 'limit' displays the number of cities as per set by you.
I had a doubt,order by clause is applied only on len of city name ,does sorting of same length cities alphabetically happen implicitly . If it did happen by default ,what would be the query if we wanted it to be in desc order alphabetically
I don't think it would work if the there are multiple cities with minmum length
for eg : Ame Aao Azi
You might have to sort it first.