<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,

> This approach doesn't work if you have gaps in your keys,
> such as after you delete a row. For example, in my case,
> if your ID's were 1, 51, 101, etc. It would return the
> first 50 entries, regardless of what their ID's were. In
> your case, the COUNT doesn't tell you the ID's of the
> records you are looking for. So if your first query
> returned 100, and you then queried for records with ID >
> 50 and ID < 100, you would only get 1 row, instead of the
> 50.

> 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




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:217070
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to