Instead of doing one query, do two with the second query using a WHERE
clause that matches the result id from the first. Then you can make
separate cfoutputs and you won't get a "nested cfoutput" error. I'm not
sure which table ids match what so I'm guessing here in this sample but it
will give you the gist.
<CFQUERY NAME="notices" DATASOURCE="newsAndNotices">
SELECT n.noticeID, n.title, n.url, n.information, d.iconPath
FROM notices n, documents d
WHERE notice.docType = documents.docTypeID
</CFQUERY>
<CFQUERY NAME="subnotices" DATASOURCE="newsAndNotices">
SELECT title, docType
FROM subnotices
WHERE noticeID=#notices.noticeID#
</CFQUERY>
Now you can display like:
<CFOUTPUT query="notices">
#title# #url# #information# #iconPath#
</CFOUTPUT>
<CFOUTPUT query="subnotices">
#title# #docType#
</CFOUTPUT>
OR you can even do this:
<CFOUTPUT query="notices">
#title# #url# #information# #iconPath# #subnotices.title#
#subnotices.docType#
</CFOUTPUT>
Hope that helps.
Bonnie E. Betts
[EMAIL PROTECTED]
www.interacttechs.com
----- Original Message -----
From: "Aimee Abbott" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Sunday, April 15, 2001 12:58 PM
Subject: two queries (nested cfoutput?)
>
> 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