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 trying to do is select 2 columns (state and state_name), I want only unique rows that do not have duplicate values for the state field. I don’t care if there are duplicate values in the state_name field.
Is my query checking both columns for uniqueness or just state?
DISTINCT will return only distinct rows, so:
Both columns
You could also switch to GROUP BY instead.