Query Of Query Not Working
What is wrong with this query of query... Basically it seems like the "IF" logic in the select statement isn't looking at the current results, but instead the first line of the AllCategories() query. Any ideas would be much appreciated.
<cffunction name="getCategoryDetail" returntype="query" >
<cfargument name="CategoryID" default="">
<cfset AllCategories = Application.Celerant.QueriesCached.getAllCategories()>
<cfquery name="CategoryDetail" dbtype="query" >
SELECT
*,
<cfif AllCategories.typ eq 'EMPTY'>
'DEPT' as ThisLevel,
AllCategories.Dept as ThisName
<cfelseif AllCategories.subtyp_1 eq 'EMPTY'>
'TYP' as ThisLevel,
AllCategories.typ as ThisName
<cfelseif AllCategories.subtyp_2 eq 'EMPTY'>
'SUBTYP_1' as ThisLevel,
AllCategories.subtyp_1 as ThisName
<cfelseif AllCategories.subtyp_3 eq 'EMPTY'>
'SUBTYP_2' as ThisLevel,
AllCategories.subtyp_1 as ThisName
<cfelse>
'SUBTYP_3' as ThisLevel,
AllCategories.subtyp_1 as ThisName
</cfif>
FROM
AllCategories
WHERE
AllCategories.web_taxonomy_id = #arguments.CategoryID#
</cfquery>
<cfreturn CategoryDetail>
</cffunction>
