First I will give an example of the table in question.
id | country | reference
1 | UK | 44
2 | UK | 514
3 | UK | 221
4 | USA | 993
5 | USA | 472
6 | USA | 092
I want to write a query that will list every distinct country and will also list any one id along with it. Here is an example of what i would like produced.
id | country
1 | UK
4 | USA
The way i do it at the moment is to issue:
select distict country from table
And then i do the following for every country produced above:
select id from table where country='countryname' limit 1
I'm sure there is a quicker way to do this but I just cannot find it.
Hope somebody can help.