MySQL query with DISTINCT keyword

后端 未结 5 849
醉酒成梦
醉酒成梦 2021-01-24 05:23

My MySQL table country_phone_codes looks something like this

id     country_code     area_code     name
---------------------------------------------------------         


        
5条回答
  •  没有蜡笔的小新
    2021-01-24 05:57

    You need to group your country_code also then & then only you will get correct matching results.

    SELECT country_code,name
    FROM country_phone_codes 
    group by country_code
    ORDER BY country_code
    

    And we should need to avoid use of Distinct in select clause as it gives performance issues. Instead of that we can use group by

提交回复
热议问题