Results 1 to 11 of 11

Thread: Select 10 rows at a time

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Swe
    Posts
    14
    Is it possible to run a select statement, e.g "SELECT * FROM <TABLE>" where the table contains 100 rows, and only get for example 10 rows at a time?

    I don´t want to fill my recordset with all 100 rows at once, I just want to fill it with 10 rows at a time and then empty the rs and fill it up with another 10 rows.

    I´m going to create a searchfunction which returns 10 rows per page, like Altavista and so on. I have found out that filling the recordset with all rows at once could make it all rather slow.
    Jesse

  2. #2

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ....

    SET ROWCOUNT 10

    prior to running your query


  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Set rowcount will not do it. Because it will return the same 10 rows each time.
    Set rowcount is usefull if you want to get a sample of the data.
    Kovan's correct, the pagesize (which is 10 records by default by the way), pagecount, and absoluteposition properties are what your looking for..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try the LIMIT statement.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Fine if you aren’t using DAO…

    Funnily enough, I have to do a similar process, but using Access97 only. Although I haven’t started, I expect my approach will be using bookmarking in recordsets

    Gaffer

  7. #7
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    Sorry... I misread the question

  8. #8
    Guest
    Hi, how about this for an idea...

    "Select * from <table name> where id >= 1 and id < 10"

    After this i would store my last id into a temporary variable and then use this value in my subsequent query

    "Select * from <table name> where id >= " & myvariable & " and id < " & myvariablevalue + 10 & "

    Should be something similar to this...

    Sorry if this doesnt help you...all the best...vijay

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use this:
    Code:
    SELECT * FROM table LIMIT 0, 10
    SELECT * FROM table LIMIT 10, 20
    ...and so on.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    hi

    does not on SQL server though

  11. #11
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    like i said in my original post
    use the ADO .pagesize, .absoluteposition and .pagecount
    very simple..

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