I have have a problem in doing the cold fusion output (or the query) from
three tables. I have simplified my example to just the part that is the
problem -- hopefully I haven't simplified it too much. Basically I want a
nested cfoutput to do what I want, I would like to know if this is because
my design is flawed somewhere else. The tables are as follows.
notices table
noticeID
docType
title
url
information
the second is all of the supporting documents for the notices,
subnotes table
subNoteID
noticeID (relationship to notices.noticeID)
title
docType
the third, is all the icons.
documents table
docTypeID
type
iconPath
Now I would like to do a query that pulls all the notices, then I would
like to do another query for the sub documents. What I would like to do
(but can't)
<CFQUERY NAME="notices" DATASOURCE="newsAndNotices">
select notice.noticeID, notice.title, notice.url, notice.information,
documents.iconPath
from notices, documents
where notice.docType = documents.docTypeID
</CFQUERY>
<cfoutput query="notices">
<img src="#iconPath#"> <a href="#url#">#title#</a>
<CFQUERY NAME="subs" DATASOURCE="newsAndNotices">
select subnote.title as subTitle, subnotes.url as subUrl,
documents.iconPath as subIcon
from subnote, documents
where notice.noticeID = subnote.noticeID and
subnote.docType = documents.docTypeID and
subnote.noticeID = #noticeID#
</CFQUERY>
<cfoutput query="subs"> <<< This is where the trouble is!
<img src="#subIcon#"> <a href="#subUrl#">#subTitle#</a>
</cfoutput>
</cfoutput>
You see what I want? I would really like a nested cfoutput. Do I really
want this because my query is flawed? I tried origianally to get this all
in one query, by doing joins but I got back results that had copys of all
the notices for each of the subdocuments (so if I had five sub documents
for a particular notice I got five query results containing the notice --
and the icon always seem to match the first result) The method I am using
now logically does what I want it to do, I just can't seem to output it
this way.
Does anyone have any suggestions for what I can do?
--Aimee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists