What do you mean with querying a query?
If you want to have a "nested" query you
can always use a <CFINCLUDE> tag.
You insert the CFINCLUDE on the template
of the first query and on the "included"
template you write your second query.
Your second query can use the variables
of the first template.
Is this understandable?
Else explain the problem with an example please.
SU
VETO
Yeah, I have. It's pretty nice - and very easy.
Run a regular database query, e.g.:
<cfquery name="myQuery" datasource="#ds#">
SELECT fname, email FROM people
WHERE gorgons = 3
</cfquery>
Then you can treat the resulting recordset just
like a data table in a later query (or several),
like:
<cfquery name="aolSearch" dbtype="query">
SELECT fname FROM myQuery
WHERE email LIKE '%@aol.com'
</cfquery>
That's all there is to it. It's just a matter of
adding the dbtype attribute to the second query,
rather than the datasource attribute, and then
being sure to reference the earlier query in the
SELECT statement of the second one.
It's actually pretty damn handy, even though this
goofy example would be a poor use of the feature.
This works only in CF 5.0 but it works! The first two queries are from two different databases. The third queries the results of the two and joins on the origin.
Query of queries type functionality can be accomplished using SQL server or other DBMS, but CF will let you combine ANY type of query including LDAP queries (CFLDAP), email queries (CFPOP), or even Verity collections using CFSEARCH.
<!--- get a combined record set filtered from the two previous record sets --->
<CFQUERY name="combined" datasource="query">
select
a.weight
, a.origin
, o.weight
, o.origin
from getApples a, getOranges o
where a.origin = o.origin
</CFQUERY>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.