Results 1 to 2 of 2

Thread: SQL question

  1. #1

    Thread Starter
    Addicted Member iehjsucker's Avatar
    Join Date
    Sep 2005
    Posts
    150

    SQL question

    how can i retrieve the top 20 from a table, then the next 20 records?

    can anybody help





    =============
    ..code masters..

  2. #2
    Member
    Join Date
    Jun 2006
    Posts
    36

    Re: SQL question

    You could start by telling your query to ORDER BY id, or some unique Integer...then, clause it with LIMIT 20.

    Get the ID of your 20th item, and place it in some variable, "LastAccessed". Then, for the next query, "SELECT * FROM table WHERE id > lastAccessed ORDER BY id ASC LIMIT 20".

    Repeat step two ("Get the ID of your 20th item, and place...")

    This should work for ya.

Posting Permissions

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



Click Here to Expand Forum to Full Width