Quantcast
Viewing all articles
Browse latest Browse all 21760

Re: Query of Search Results

Thank you all for your input.  As a follow-up to what seems to have helped and to help others is a description below.

 

I was having trouble getting an accurate recordcount of companies using the primary query (search results) because it was creating rows for the joined tables with a one-to-multi relationship.  It was accurately counting all the rows (multiple codes) returned and not just the distinct field (company) that I needed.

 

I worked around it by using query of queries to get the accurate recordcount off of that primary query (companies used in previous example which I will rename as getcompanies since it is the same name as a table column).

 

<cfquery dbtype="query" name="records">

Select distinct company

from getcompanies

</cfquery>

 

I then output each company record and their associated codes by using another QoQ:

 

<cfoutput query="getcompanies">

 

<cfquery dbtype="query" name="getcodes">

Select codes

from getcompanies

where companyid= <cfqueryparam value="#getcompanies.companyid#" cfsqltype="cf_sql_integer">

and code is not null

</cfquery>

 

#company# Codes:</strong> #valuelist(getcodes.codes, ", ")#

 

</cfoutput>

 

If anyone knows of a more efficient way, I always welcome the suggestions.  It seems to have reduced the execution time from 16K ms to 6K ms, but I'm still trying to get the execution time down to under 250 ms.  There are only 800 records.


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>