If it's SQL Server or Access use:

SELECT TOP 2 article_id, article_title, date_entered
FROM articles
ORDER BY article_id DESC

But read this:

http://articles.techrepublic.com.com/5100-22_11-5035113.html

mySQL:

SELECT article_id, article_title, date_entered
FROM articles
ORDER BY article_id DESC
LIMIT 0, 2

Adrian

-----Original Message-----
From: John Barrett
Sent: 20 December 2007 07:54
To: CF-Newbie
Subject: cfquery-latest entry


I have a datbase with 382 article. With loys of help from this list I was
able to get many aspects working, but the one thing that I can't figure out
is how can I get the latest article, and the latest article -1. This I mean
last weeks, and 2 weeks ago, the last two entries in the db.

I know I could call the article_id by number, such as #382 for the last one,
and #381 for the second to last one, but I want the app to be dynamic. There
must be a way to do this, and I would really be greatful for any help.

Thanks,
John

here is how I get the first year:
<cfquery name="get_articles" datasource="articles">
        Select article_id, article_title, date_entered from articles
 </cfquery>

<!--- (This gets the first year)
Select article_id, article_title, date_entered from articles where
article_id >= "1" and article_id <= "12" --->


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:3206
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