Isaac,

This won't work either, because it is possible that some of the ID's between 2 
and 52 did not match your original WHERE clause in the first query. Say 
qry1.id[1] was 2 and qry1.id[50] was 10,000. Then in your second query, you are 
pulling almost 10,000 records, instead of the 50 that you wanted! Again, this 
is why my original post used the ID IN () to only get the records you wanted.

I went through this discussion by myself about a year ago when I came up with 
this :) Funny to see everyone has sort of the same though process. Also, this 
solution works independent of the DB, whether it be Access, MySQL, etc, since 
no sub-queries are needed.

Cedric

><cfquery name="qry1" ...>
>       select id from mytable where ...
></cfquery>
>
>^ gets all id's for applicable records in the table -- we knew this
>
><cfset startid = qry1.id[1]>
><cfset endid = qry1.id[50]>
>
>^ this does rather assume that you're using either autonumbers or
>another sequential numeric identifier for id's in that table, however,
>at this point, you now know the first and last ID of the first 50
>records... so for instance if the table started with id 1 and you
>deleted 1 and 5, you would have
>
>startid = 2
>endid = 52
>
><cfquery name="qry2" ...>
>       select * from mytable
>       where id between #stardid# and #endid#
></cfquery>
>
>^ (no queryparam's I know) ... at this point, since startid is 2 and
>end-id is 52, you're actually getting the first 50 records (52-1 = 51
>then subtract the one from the middle, record 5 which was also
>deleted, gives you 50 records)
>
>hth
>
>> Dave,
>
>
>> Unless I missed your point completely :)
>
>> Cedric
>
>
>s. isaac dealey   954.522.6080
>new epoch : isn't it time for a change?
>
>add features without fixtures with
>the onTap open source framework
>
>http://www.fusiontap.com
>http://coldfusion.sys-con.com/author/4806Dealey.htm

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:217072
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to