First I will give an example of the table in question.
id | country | inuse | reference
------------------------------------------------
1 | UK | 1 | 44
2 | UK | 1 | 514
3 | UK | 0 | 221
4 | USA | 1 | 993
5 | USA | 0 | 472
6 | USA | 1 | 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.
id | country | inuse | reference
------------------------------------------------
1 | UK | 1 | 44
2 | UK | 1 | 514
3 | UK | 0 | 221
4 | USA | 1 | 993
5 | USA | 0 | 472
6 | USA | 1 | 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.