mySQL distinct column
i am returning 3 columns in a select query but i only want it to return distinct rows based on the first 2 columns
e.g
COL1 COL2 COL3
X Y 1
X X 1
X Y 2
should return the 1st and second row
distinct seems to pull back only distinct whole rows
[362 byte] By [
jim_scott] at [2007-11-19 18:55:55]

# 1 Re: mySQL distinct column
distinct seems to pull back only distinct whole rows
It is designed to do that ;).
should return the 1st and second row
And what should be displayed for 3rd colum ( 1 or 2 or something else)?:rolleyes:
Post required output!
Best regards,
Krzemo.
Krzemo at 2007-11-9 13:43:18 >

# 2 Re: mySQL distinct column
Krzemo is absolutely correct! It would be tough to decide as to what you want as value for the non-distinct column. That does not make sense!
Alternatively, there is another version of distinct that one can use - DISTINCT ON (<columns or set of columns>) <columns to select>. See if your db supports that and the output makes sense to your requirement. Regards.