www.webdeveloper.com
Results 1 to 5 of 5

Thread: limiting a query

  1. #1
    Join Date
    Jan 2003
    Location
    Israel
    Posts
    1,381

    limiting a query

    can i linit a query like in mysql Server where i can ask in the query
    lines 20-30 like this:
    select * from table1 limit 20,10
    which means tgive me the first 10 rows sarting with line 20
    thnaks in advance
    peleg

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Are you using MS Access? If so, I do not think you can limit the query in the same way. You may be able to, but I have never come across it.

    You can, however, use the TOP clause.
    Code:
    SELECT TOP 10 * FROM TableName ORDER BY TableNameID;
    If you're using MS SQL, you may be able to use a CASE or similar conditional statement to begin ordering at a certain point. See: http://www.siteexperts.com/forums/vi...d=17279&Sort=0

    Regards.

  3. #3
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298

  4. #4
    Join Date
    Jan 2003
    Location
    Israel
    Posts
    1,381

    well 2 thins

    i work with sql server
    and what i wanted to do is paging - sorry for not using the correct word from starts!
    the link i used is :
    http://www.asp101.com/articles/recordsetpaging/index.asp
    and the solution that buntine gave me in the link i have a better 1 i belive :
    PHP Code:
    select top 5
     

    from 
    (
                
    select top 10
                 
    *
                
    from 
                 companies
                order by row_num DESC
    )aa
    order by row_num DESC 
    simple isnt it but not effective when i have 1 million rows!

  5. #5
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    But good enough.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles