Wordpress Themes - Wordpress Themes - Debt Consolidation - Arcade Games - Debt Consolidation

PDA

View Full Version : Distinct one columnt, including the second column


mahmood
Apr 8th 2006, 8:29 pm
I am trying to select 2 columns of a table, one of the distinct.

At the moment I have this code working:
SELECT DISTINCT `Town` FROM myTable

Say it returns 10 result, now I want the ID columns with these results too.

If I code:

SELECT DISTINCT `Town`,`ID` FROM myTable

It'll return far more result than I expect. I need only the same ten results but including ID.

Any idea?

vectorgraphx
Apr 13th 2006, 1:21 pm
ditch the distinct, try using the group by clause.

SELECT `Town`,`ID` FROM myTable GROUP by `Town`