Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello


how to select 5 to 15 rows over 100 records
Posted

As you haven't said how you want to do this I believe that you can do it 2 ways

1. LINQ

VB
dim q = (from x in User_object select x).skip(5).take(10)


How to: Return or Skip Elements in a Sequence (LINQ to SQL)[^]

2. SQL

SQL
SELECT top 10 *  --this takes the first 10 records of the reversed 15 records
FROM (
      --This takes the first 15 records and orders them descending by the id_field
      SELECT TOP 15 *
      FROM table
      ORDER BY id_field DESC
     )
 
Share this answer
 
I have no idea about your database structure, so i guess this abstract code would be helpful.
SQL
SELECT TOP (10) *
FROM Table1
WHERE [SomeIDField] NOT IN (
    SELECT TOP (5) [SomeIDField]
    FROM Table1
    )
 
Share this answer
 
Comments
Bala Selvanayagam 4-Nov-11 19:04pm    
5ed
Maciej Los 5-Nov-11 16:03pm    
Thank You
RaviRanjanKr 5-Nov-11 10:55am    
My 5+
Maciej Los 5-Nov-11 16:03pm    
Thank You
following Query gives your first 15 records.

SQL
SELECT TOP 15 * FROM Persons
 
Share this answer
 
Comments
Mehdi Gholam 4-Nov-11 2:51am    
5'ed
Maciej Los 4-Nov-11 17:34pm    
1 - becouse of vianyfirstblock comment.
vinayfirstblock 4-Nov-11 3:28am    
i want 5 to 15 records only means 10 records starting from 5th to 15th record,
not top 15 records

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900