Brian, thanks for the reply; I have to admit that I'm stronger with CF and
DB Design than with the actual SQL (bad man! bad!) <grimace!>

-----Original Message-----
From: Brian Panulla [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 16, 2002 5:11 PM
To: CF-Linux
Subject: Re: CF Code Q


At 04:51 PM 7/16/2002 -0400, you wrote:
>I'm trying to create a dynamic browse; i.e. the user drops into a record
>located by PK and then I need to find out how many records AFTER and BEFORE
>that record exist. Any ideas?


You using CF5? Sounds like a job for Query of Queries. Don't know if there
are any efficiency problems with this, but at least it only hits the
database once.

<code>
<!--- You should probably cache this query if you can --->
<cfquery name="qryAllRecords" datasource="foo" dbtype="odbc">
         SELECT * FROM tblMyTable
</cfquery>

<cfquery name="qryThisRecord" dbtype="query">
         SELECT * FROM qryAllRecords WHERE npkRecordID = #SOMEVALUE#
</cfquery>

<cfquery name="qryCountBefore" dbtype="query">
         SELECT count(*) AS BeforeCount FROM qryAllRecords WHERE
npkRecordID < #SOMEVALUE#
</cfquery>

<cfquery name="qryCountAfter" dbtype="query">
         SELECT count(*) AS AfterCount FROM qryAllRecords WHERE
npkRecordID > #SOMEVALUE#
</cfquery>

</code>

-B




_____
Brian Panulla                           [EMAIL PROTECTED]
Chief Information Officer               814.238.6680
Elmwood Media Group                     www.elmwoodmedia.com


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-linux%40houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_linux or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to