Hi,
I have a DB table with 3 columns.
table(details)
columns(id, cities, address)
I need to select DISTINCT cities in column 2 but i also need to use the id column in the result.
If I use a query like this:
SELECT DISTINCT cities FROM details
then I will get all the distinct cities that I need. However, the id column wont be available in my result set as it wasn't included in the select.
Now, if I used a statement like this:
SELECT DISTINCT id, cities FROM details
I will get a lot of duplicate cities because, when combined with the id column, every combination will be distinct because each value in the id column is an auto_increment value and no 2 are the same.
Does anyone know how I can select the distinct cities in my DB but also have the id value available in my result set without it messing upo the results I want?
Thanks in advance,
Martin