For a few reasons.  First, it necessitates that the placement of the last
active record (in your code sample, row 3) is known ahead of time (which it
isn't).  Second, if there is 1 or less available records "above" the last
known active record, your solution doesn't allow for returning to earlier
records.

--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 625-9191
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/


> -----Original Message-----
> From: Costas Piliotis [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 7:42 PM
> To: CF-Talk
> Subject: RE: Finding next 2 items in query
>
>
> Uh, why not just use <cfoutput query="foo" startrow="3"
> maxrows="2"> out of
> curiosity?
>
> -----Original Message-----
> From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 3:20 PM
> To: CF-Talk
> Subject: RE: Finding next 2 items in query
>
>
> You're explaining yourself just fine.  No worries.
>
> Basically, you're looking at some conditional logic a few
> queries. Something
> like this:
>
> 1) Query DB for currently active items, sort by ID.
> 2) Discard the 1st record and store the ID of the 2nd.
> 3) Update DB to make currently active item inactive.
> 4) Query DB for all items greater than stored value that are
> approved, sort
> by ID.
> 5) a) If RecordCount >= 2, grab 1st 2 values and ignore others.
>    b) Else, query DB for all approved items, sort by ID.  Grab 1st 1 or 2
>       depending on how many you got from the previous query.
> 6) Update DB to set these 2 values to active.
>
> Note that in the 5b, you're getting all approved items, not just
> those less
> than the last 2 approved items.  This is just in case you only
> have to items
> that are currently approved.
>
> --
> Mosh Teitelbaum
> evoch, LLC
> Tel: (301) 625-9191
> Fax: (301) 933-3651
> Email: [EMAIL PROTECTED]
> WWW: http://www.evoch.com/
>
>
> > -----Original Message-----
> > From: W Luke [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, September 20, 2002 12:08 PM
> > To: CF-Talk
> > Subject: Re: Finding next 2 items in query
> >
> >
> > > ----------------------
> > > ID* - Active - Approved
> > > ----------------------
> > > 12  - No     - Yes
> > > 23  - No     - No
> > > 24  - No     - Yes
> > > 29  - Yes     - Yes
> > > 32  - Yes     - Yes
> > > 33  - No     - Yes
> > > 40  - No     - No
> >
> > > I think you'll have to fill us in on why 33, and 12 "meet the
> > > criteria"
> >
> > Because they're the "next" records in the table WHERE Approved = Yes
> > AND active = No.  40 has to be ignored because Approved = No.
> >
> > I know how to find all records that are "approved," or "active," or
> > whatever - but I don't see how I can get the "next 2."  A friend
> > suggested doing something like WHERE ID > #previousID# - only problem
> > with this is if the CURRENT ID was 40 (as per the table above), it
> > wouldn't pickup on 12 which is the logical next record.
> >
> > Sorry, I'm not explaining myself properly here at all - if anyone has
> > any other ideas they'd be much appreciated
> >
> > Will
> >
> >
>
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to