Results 1 to 7 of 7

Thread: SELECT the next 3

  1. #1
    Join Date
    Oct 2004
    Posts
    27

    SELECT the next 3

    How can I get the next 3 rows from a query ?

    1 to 3
    then
    4 to 7
    ect ....

    something like
    SELECT TOP (4 to 7) id FROM myTable ORDER BY id DESC

    will be great :-)

    thank you

  2. #2
    Join Date
    Nov 2004
    Posts
    5

    Use DAO/BVA

    An SQL guru may have a different take on this, but I would use a DAO recordset in code that filters out each iteration of a TOP 3 query on the previous result...

  3. #3
    Join Date
    Feb 2003
    Posts
    1,048
    You have two choices:

    1. Use pagination where you specify a page size of 3 and keep fetching the next page.

    2. Use a field with unique entries (like an autonumber field) that you can use for a reference.

    Select Top 3 *
    From myTable
    Order By keyField
    Where keyField > "largest keyField value returned in last query"

  4. #4
    Join Date
    Oct 2004
    Posts
    27
    pagination is nearlly never the best way...
    im my case most part of customers will never turn the next page
    ... it is unnecessary to load 1000 rows for 10 percent of customers

    --------------------

    Rawhide >>> of course I need the second choise


    Select Top 3 *
    From myTable
    Order By id
    Where id > "largest id value returned in last query"

    is just ..... great :-))))


    thank you
    Last edited by gwendaal; 11-30-2004 at 03:18 AM.

  5. #5
    Join Date
    Feb 2003
    Posts
    1,048
    I must admit that I never use pagination myself, but still i felt compelled to mention it.

  6. #6
    Join Date
    Oct 2004
    Posts
    27
    it works allready and that's really a great idea ....
    I use a generally a normal datapaging component ....

  7. #7
    Join Date
    Oct 2004
    Posts
    27
    it works very well to get datas but if you need to sort by columns it doesn't work any more

    is there any way to get the row index not depending on values ?

    Select Top 10 myTable.*
    From myTable
    Where myTable.RowIndex > lastRowIndex

    of course RowIndex is not a column Name

    thank you

Posting Permissions

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