|
-
Nov 8th, 2005, 10:25 PM
#1
Thread Starter
Addicted Member
DB Question just asking
is it possible to select the 5th record until the 30th record in a sql query?
-
Nov 8th, 2005, 10:58 PM
#2
Frenzied Member
Re: DB Question just asking
Not sure if there is a shortcut.
I would load the query into a datatable and iterate through the datatable as follows:
VB Code:
Dim str As String
Dim myDataTable As New DataTable
'Populate your datatable with all rows
For i = 4 to 29 'row numbers 5 to 30
'assign the value of the first field in row i to str
str = myDataTable.Rows(i).Item(0)
Next
-
Nov 8th, 2005, 11:00 PM
#3
Thread Starter
Addicted Member
Re: DB Question just asking
i know that, i am just asking on the sql part if it is possible?
-
Nov 9th, 2005, 04:13 AM
#4
Hyperactive Member
Re: DB Question just asking
Check out the top method not sure if you can amend that?
-
Nov 9th, 2005, 04:19 AM
#5
Thread Starter
Addicted Member
Re: DB Question just asking
SELECT *
FROM (Select top 30 * from Products) where productID > 4;
-
Nov 9th, 2005, 04:23 AM
#6
Hyperactive Member
Re: DB Question just asking
-
Nov 9th, 2005, 04:25 AM
#7
Thread Starter
Addicted Member
Re: DB Question just asking
it did work. Try it on your Northwind database. it will work:-0
-
Nov 9th, 2005, 04:31 AM
#8
Hyperactive Member
Re: DB Question just asking
Glad i could help!
-
Nov 9th, 2005, 05:14 AM
#9
Frenzied Member
Re: DB Question just asking
 Originally Posted by iehjsucker
SELECT *
FROM (Select top 30 * from Products) where productID > 4;
It will work provided that a product with ProductID between 1 and 4 (inclusive) has not been deleted. If this is the case, then ProductID 5 can at most be the fourth record and should be excluded but will not be excluded according to the WHERE clause above.
-
Nov 10th, 2005, 04:48 AM
#10
Frenzied Member
Re: DB Question just asking
You could populate a datatable with "Select top 30 * from Products" then:
VB Code:
For i = 0 to 3
myDataTable.Rows.RemoveAt(i)
Next
to remove the first 4 rows.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|