Select article_id, article_title, date_entered from articles order by date_entered desc limit 2
The 'limit 2' works with mysql but not mssql, so you may need a different way to limit rows returned or displayed. I believe the the cfoutput tag has a parameter for limiting the number of records processed. The 'desc' in the sql reverses the fetch order. On Dec 20, 2007, at 2:53 AM, John Barrett wrote: > 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:3208 Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
