MySQL - SELECT the name that comes first alphabetically

后端 未结 11 1539
悲&欢浪女
悲&欢浪女 2020-12-24 08:50

I have started to learn MySQL.

Here is the table world:

+-------------+-----------+---------+
|    name     | continent |  area   |
+--         


        
11条回答
  •  既然无缘
    2020-12-24 08:58

    Try this

    select distinct  w.continent, 
                     (select w2.name 
                      from world w2 
                      where  w.continent =  w2.continent 
                      order by name asc 
                      limit 1) name 
    from world w
    order by w.continent
    

提交回复
热议问题