faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Oracle

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

65 of 107 people (61%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How to split the result into pages, like 'limits' in MySQL? (PHP4+Oracle 8i)

Jan 20th, 2001 19:01
Alistair McElligott, Petr Kocian, Wenjun Shen,


You have to use subselect. The inner query selects all records and 
every record will get its number rn. The outter query then selects just 
required interval of records.
to select records from 51 to 100 use condition like this:
SELECT * FROM 
   (SELECT some_fields, ROWNUM rn FROM some_table)
WHERE rn BETWEEN 51 AND 100
Important is to use alias of the ROWNUM field in the inner query.
This sollution is a little uneffective because the inner query will 
select all records.
This approach doesn't work if you have an order-by clause, as the 
ordering (on the subquery) is performed _AFTER_ the row numbers are 
allocated.