<CFQUERY DATASOURCE="???" NAME="getcomments">
SELECT U.UserID,Username,CommentID,Comment
FROM Users U LEFT OUTER JOIN Comments C ON U.UserID = C.UserID
Order By U.UserID, CommentID
</CFQUERY>

<CFOUTPUT query="getcomments" group="UserID">
#UserID#,#UserName#<CFOUTPUT><br>#Comment#</CFOUTPUT>
</CFOUTPUT>



>Perhaps this is easy for someone so I figured I'd ask.  Here's the scenario:
>
>USERS TABLE
>-----------------
>USER_ID
>USERNAME
>etc...
>
>COMMENTS TABLE
>-------------------------
>COMMENT_ID
>USER_ID
>COMMENT
>etc...
>
>I know I can query USERS and then loop through the results fetching the
>comments... but I'd rather not do that.  Here's the results I'm trying to
>get... in a SINGLE query if possible:
>
>USER_ID,USERNAME,MERGED_COMMENTS
>1,joe,comment1<br>comment2<br>comment3
>2,sam,comment
>3,sue,comment<br>another comment<br>etc.
>
>Any ideas?


-- 

Bud Schneehagen - Tropical Web Creations, Inc.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Web Based Solutions / eCommerce Development & Hosting
http://www.twcreations.com/ - http://www.cf-ezcart.com/
954.721.3452 - Toll Free: 877.207.6397 - Fax: 954.721.7493
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to