How do scrub out duplicates in a list?
This is what I am doing:
1) I first query the dB
<cfquery name="getLocations">
select country, state, city
from locations
</cfquery>
2) then take the records and put them in a 'quotedvaluelist' list.
<cfset CountryList = #quotedvaluelist(getLocations.Country)#>
<cfset StateList = #quotedvaluelist(getLocations.State)#>
<cfset CityList = #quotedvaluelist(getLocations.City)#>
Now the problem is the the Country and State have duplicates in which i'd like to scrub out from the list, whats the best way I can do that?
The alternative is having 3 seperate queries (one that returns a distinct country, state and city) and then place them in my list. I'd like to avoid running 3 queries when i can do that in one.
Any ideas?
____________________________________
Just Imagine.
This is what I am doing:
1) I first query the dB
<cfquery name="getLocations">
select country, state, city
from locations
</cfquery>
2) then take the records and put them in a 'quotedvaluelist' list.
<cfset CountryList = #quotedvaluelist(getLocations.Country)#>
<cfset StateList = #quotedvaluelist(getLocations.State)#>
<cfset CityList = #quotedvaluelist(getLocations.City)#>
Now the problem is the the Country and State have duplicates in which i'd like to scrub out from the list, whats the best way I can do that?
The alternative is having 3 seperate queries (one that returns a distinct country, state and city) and then place them in my list. I'd like to avoid running 3 queries when i can do that in one.
Any ideas?
____________________________________
Just Imagine.