Bill, Although you cannot get a count of the number of rows in a table without performing some kind of query, the following is a bit better:
<CFQUERY name="name" datasource="datasource"> SELECT Count(*) AS RecordCnt FROM tblFoo </CFQUERY> You can then refer to name.RecordCnt for the number of records. This is better in that the database only has to return one record to CF, whereas using the other method causes the database to return many records. I have seen many debates about whether you should use Count(*) or Count(ID). This supposedly differs between databases, but I'd guess that any db worth its salt will be able to properly optimize a Count(*) query. Bob P.S. Sorry I haven't posted that promised "Caching with Structures" example code yet. I just returned from a week's vacation, so I hope to get it done soon. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of Bill Sourour > Sent: Monday, 25 February 2002 6:56 p.m. > To: [EMAIL PROTECTED] > Subject: [CFTALKTor] RecordCount > > > Before my question, I am obliged to say: > > "GO CANADA! GO! ... WE ARE THE BEST HOCKEY PLAYERS ON EARTH BABY!!!" > > ok, now that that's out of the way. > > Is there a way to return a record count for a given table whithout > performing a query? To clarify: > > here's what I do now: > > <CFQUERY name="name" datasource="datasource"> > SELECT ID > FROM tblFoo > > </CFQUERY> > > Then I can use #name.recordcount#. But I never use the ID for > anything, the > sole purpose of that query is to get a record count. This strikes me as > inefficient. Any suggestions? > > Thanks in advance. > > - > You are subscribed to the CFUGToronto CFTALK ListSRV. > This message has been posted by: "Bill Sourour" <[EMAIL PROTECTED]> > To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/ > Manager: Kevin Towes ([EMAIL PROTECTED]) > http://www.CFUGToronto.org/ > This System has been donated by Infopreneur, Inc. > (http://www.infopreneur.net) > - You are subscribed to the CFUGToronto CFTALK ListSRV. This message has been posted by: "Bob Silverberg" <[EMAIL PROTECTED]> To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/ Manager: Kevin Towes ([EMAIL PROTECTED]) http://www.CFUGToronto.org/ This System has been donated by Infopreneur, Inc. (http://www.infopreneur.net)
