I have added the 'maxrows' parameter and 'order by' to your query.

<cfquery name="qGetLastPost" datasource="schoolsforums" maxrows="1">
   select max(sf_messages.posted) as lastpost,
              sf_messages.title,
              sf_users.username,
              sf_forums.id as forumid,
              sf_threads.id as threadid 
   from (((sf_messages 
           left join sf_threads on sf_messages.threadidfk = sf_threads.id)
           left join sf_forums on sf_threads.forumidfk = sf_forums.id)
           left join sf_users on sf_messages.useridfk = sf_users.id)
   where sf_forums.id = 'CD4DBE82-874D-9864-ABB204DC22EC3285'
   group by sf_messages.posted
   order by lastpost desc
</cfquery>

Hope this helps,
William

-- 
William E. Seiter
 
Have you ever read a book that changed your life?
Go to: www.winninginthemargins.com
Enter passkey: goldengrove
 
Web Developer / ColdFusion Programmer
http://William.Seiter.com

-----Original Message-----
From: Walter Conti [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 15, 2008 8:25 AM
To: CF-Newbie
Subject: Select max(dateField). Help with query

The following query returns a recorderdset of 'forums' and 'lastpost' being
the last record the highest date, which is the only record I really need.
Is there a way of getting just "that" las record?
Thanks for helping.

<cfquery name="qGetLastPost" datasource="schoolsforums">
   select max(sf_messages.posted) as lastpost,
              sf_messages.title,
              sf_users.username,
              sf_forums.id as forumid,
              sf_threads.id as threadid 
   from (((sf_messages 
           left join sf_threads on sf_messages.threadidfk = sf_threads.id)
           left join sf_forums on sf_threads.forumidfk = sf_forums.id)
           left join sf_users on sf_messages.useridfk = sf_users.id)
   where sf_forums.id = 'CD4DBE82-874D-9864-ABB204DC22EC3285'
   group by sf_messages.posted
</cfquery> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3314
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to