March 8, 2004 at 3:18 am
How Do I get 10 rows at a time (i.e) 1-10 at first time and 11-20 rows at next click and so on. Can any body tell a solution or link which will explain this process. I am using Sqlserver with PHP
March 8, 2004 at 3:39 am
March 9, 2004 at 10:27 am
You could do something like this:
SELECT TOP 10 *
FROM table1
WHERE id_field NOT IN
(SELECT TOP @previous_count id_field FROM table1 ORDER BY id_field)
ORDER BY id_field
Here @previous_count is an integer denoting the start count. So on first page it will be 0, 2nd page it will be 10....
id_field could be an IDENTITY field
November 4, 2004 at 1:48 am
Try this:
It will bring you records 11-20 out of table [myTable], sorted by [sortField]:
select * from (
select top 10 * from (
select top 20 * from (
select * from myTable -- this can in fact be any search query
) a order by SortField
) b order by SortField DESC
) c order by SortField
I use this technique and it works quite well - also I can replace the innermost query with just about any search statement, such as "SELECT * FROM ... WHERE name LIKE ... AND type = ... etc.
Good luck,
- Avi
November 4, 2004 at 2:24 am
More than one way to skin that cat
http://www.microsoft.com/sql/techinfo/tips/administration/resultset.asp
http://www.aspfaqs.com/webtech/062899-1.shtml
or here
http://www.aspfaq.com/show.asp?id=2120
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply