i have a form that has ajax working corectly on a spry tab with 2 enteries... but i wan the 2nd spry to be a distinct as well as the first one ... the first spry tab has company name dropdown that is pulling the information of the company owner firs and last name as well as the address and phone number of the company... that has a distinct in the query to make sure it only pulls the company name in the dropdown one time... then the second spry is links to the company name dropdown in the first spry to show self owned propriateries of a farm name under the selected company also pulling a first and last name address and phone number of the farm... but it shows several farms with the same exact name listed several times (user error) so i want the query to pull a distinct but it also has to pull the other information as well since it is linked... any suggestions? here is the second dropdown... is there someway to possibly call the where clause to another query that would only give the distinct name? i dont know what else i could do
<cffunction name="getcontacts" access="remote" returntype="array">
<cfargument name="cid" type="string" required="no">
<cfset var rsData="">
<cfset var myReturn=Arraynew(2)>
<cfset var i=0>
<cftry>
<cfquery name="rsdata" datasource="myDatasource">
SELECT Distinct(FarmName.FarmNames), ContactInfo.CID, FarmName.FarmNameID, ContactInfo.Company, ContactInfo.Fname, ContactInfo.Lname, ContactInfo.Address, ContactInfo.City,
ContactInfo.State, ContactInfo.Zip, ContactInfo.Email, ContactInfo.Phone, FarmName.DFname, FarmName.DLname, FarmName.DAddress,
FarmName.DCity, FarmName.DZip, FarmName.DState, FarmName.Longitude, FarmName.Latitude
FROM ContactInfo LEFT OUTER JOIN
FarmName ON ContactInfo.CID = FarmName.CID
WHERE ContactInfo.Company = '#arguments.cid#'
ORDER BY FarmName.FarmNames
</cfquery>
<cfcatch type="any">
<cfset returnStruct.success = false />
<cfset returnStruct.message = cfcatch.message />
</cfcatch>
</cftry>
<cfloop query="rsdata">
<cfif rsdata.recordcount gt 0>
<cfset myReturn[rsData.currentrow] [1]=rsdata.FarmNameID>
<cfset myReturn[rsData.currentrow] [2]=rsdata.FarmNames>
</cfif>
</cfloop>
<cfreturn myReturn>
</cffunction>