Page 1 of 1

Displaying records in a cyclic fashion

Posted: Sun Jun 01, 2003 3:27 pm
by minds_gifts
How can i limit the no of records displaying from a table?To be more precisely, this is what i would like to do:

Say i've 100 records in a table.Today, I would like to show 1 to 40 records.Tomorrow from 41 to 80 and then 81 to 20 on the next day.So, something like in a cyclic fashion.

Would be glad if somebody can help me.

Many thanks

Posted: Sun Jun 01, 2003 9:49 pm
by fractalvibes
Use the Limit clause if this is a MySql database:

From the Manual:
=================
SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15
To retrieve all rows from a certain offset up to the end of the result set, you can use -1 for the second parameter:
mysql> SELECT * FROM table LIMIT 95,-1; # Retrieve rows 96-last.
If one argument is given, it indicates the maximum number of rows to return:
mysql> SELECT * FROM table LIMIT 5; # Retrieve first 5 rows
==================

I think SqlServer has a similar function - Top N
DB2's flavor uses Fetch First N only

Phil J.