MySQL Select DISTINCT multiple columns based on the uniqueness of one row?

后端 未结 2 1661
你的背包
你的背包 2021-01-17 22:46

I\'m trying to understand what this query does exactly:

SELECT DISTINCT `state`, `state_name` FROM `geo` ORDER BY `state_name` ASC

All I\'m

2条回答
  •  有刺的猬
    2021-01-17 23:29

    It's checking for unique combinations of state and state_name. Distinct operates on all columns included in your select list.

    To only include unique state values, just select distinct state

提交回复
热议问题