Entry
In a sql query,how do u get the first 50 records,when the where clause selects more, say 200 or 1000, without loops and cursors
May 21st, 2002 09:23
Red Slug, Narendra Jain, Jayanta Barua, http://www.orafaq.com/faqsql.htm
Use the LIMIT clause of the SQL as below:
select * from tablename LIMIT $start_position, $num_of_rows
e.g. If you need 10 results starting at 30th position, the query would
look like:
select * from tablename limit 30, 10
You could thus program 2 buttons 'Next' and 'Previous' to generate the
query accordingly.
Hope this helps...
Narendra Jain
---------------------
The above is actually incorrect as there is no LIMIT keyword in Oracle.
There is no really neat solution, but this works:-
SELECT *
FROM tableX
WHERE rowid in (
SELECT rowid FROM tableX
WHERE rownum <= 7
MINUS
SELECT rowid FROM tableX
WHERE rownum < 5);
Look at this link for confirmation:-
http://www.orafaq.com/faqsql.htm