First write your sql as

SELECT p.photoID, p.photoTitle, c.commentId, c.commentText
FROM    photos p
                 LEFT OUTER JOIN comments c
                     ON c.photoid_fk = p.photoid
ORDER BY p.photoID, c.commentID

Then output the query using cfoutput and group like this

<ul>
<cfoutput query="yourQuery" group="photoID">
   <li>#photoTitle#</li>
      <ul>
      <cfoutput>
         <li>#commentText#</li>
      </cfoutput>
      </ul>
</cfoutput>
</ul>

HTH

Qasim
On 7/22/07, Joel Watson <[EMAIL PROTECTED]> wrote:
>
> I have two tables, photos and comments.  Their structures are as follows:
>
> photos table
> ------------------
> photoID
> photoTitle
>
> comments table
> ------------------
> commentID
> commentText
> photoID_fk
>
> I need to write a query that will allow me to display all the records in
> photos while also displaying the comments that match up to each photoID
> record.
>
> Kind of like this:
>
> photoID 1
>    comment 1
>    comment 2
>
> photoID 2
>    comment 3
>    comment 4
>
> photoID 3
>    [no comments]
>
> photoID 4
>    comment 5
>    comment 6
>
> And so on...
>
> Any help would be greatly appreciated.  Thanks!
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & 
Flex 2
Free Trial 
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:284330
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to