How about something like this:
select P1.*, count(P2.postid)
from Posts p1, PostComments p2
where p1.postid=p2.postid
group by p1.postid
order by p1.postdate desc
<cfoutput query=Myquery startrow=1 endrow=5>
output here
</cfloop>
[email protected] on Monday, March 19, 2007 at 7:59 AM -0800
wrote:
>> I have two tables, Posts and PostComments, the latter of which has a
>foreign key on the PostID of Posts.
>>
>> On my output page, I am using an output query to display the latest 5
>Posts. Inside of this output query, I need to show how many comments are
>related to the particular posts.
>>
>> I have tried a million combinations of joins and attempts at some
>loops, but I cannot figure this out. All that I have been able to manage
>so far is to either show the same number for each post, or to show a
>descending number of all totals for each post. Moreover, my brain is
>nearly fried from frustration.
>>
>> This seems like it should be incredibly simple, but I am at a complete
>loss.
>>
>> Anyone have any ideas?
>>
>> Thanks!
>>
>> Joel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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-Newbie/message.cfm/messageid:2641
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15