Page 1 of 1
selecting distinct multiple columns..is that possible ?
Posted: Thu May 25, 2006 2:40 am
by dibyendrah
I want to select distinct muliple columns. select distinct(col1, col2) is not possible. Is it possible ?
Posted: Thu May 25, 2006 2:58 am
by GM
I've never seen it done before. If ever I need to do this, I concatenate the column values, and select distinct on this value.
Might be a performance issue, depending on which columns they are.
Posted: Thu May 25, 2006 4:45 am
by dibyendrah
I need to select distinct rows having multiple fields. I'm banging my head to get the solution.
Posted: Thu May 25, 2006 7:05 am
by GM
Is there no way you can do SELECT DISTINCT CONCAT(col1, col2, col3...) ?
Posted: Thu May 25, 2006 8:24 am
by timvw
Distinct ALWAYS applies to ALL the columns in the SELECT clause... Thus not only the first immediately after it...
To me it appears as if you should GROUP BY col1, col2 in order to get the result that you want...