TOP and BOTTOM help

Results 1 to 3 of 3

Thread: TOP and BOTTOM help

  1. #1
    Reggie Guest

    Default TOP and BOTTOM help

    I&#039;m using this SQL query to get the 20 newest records. Is there any way to get the rest of the records (it will be on a different page)? So if there are 50 records I want the BOTTOM 30, or if there are 100 records I want the BOTTOM 80. Any ideas?<BR><BR>SQL_query = "SELECT TOP 20 * FROM PostList"<BR><BR>SQL_query = "SELECT BOTTOM ?? * FROM PostList"

  2. #2
    Join Date
    Dec 1969

    Default Try this...

    You might be able to modify this code to do what you want:<BR><BR><BR>Otherwise, I would set up a field in your table that numbers the posts or whatever they are:<BR>do until objRS.eof = true<BR>if objRS("postNumber") &#060; 20 then<BR>response.write objRS("postNumber")<BR>else<BR>end if<BR>objRS.movenext<BR>loop<BR><BR>Hope this helps

  3. #3
    Join Date
    Dec 1969

    Default RE: TOP and BOTTOM help

    SELECT TOP 20 * FROM PostList ORDER BY someField ASC<BR><BR>Without an ORDER BY, how will you know what ordering is being used? What does TOP 20 *mean* without an ORDER BY???<BR><BR>SELECT TOP 80 * FROM PostList ORDER BY someField DESC<BR><BR>That will now get the rest of the 100 records in reverse order. So just process the recordset backwards.<BR><BR>But, really, why not use one of the many "paging" techniques that are discussed all over the place? In the FAQs here, unless I am mistaken, for one example.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts