![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 30.03.2005 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
mam problem taki jak w temacie. Robie zapytanie do Oracle które zwraca mi dużo wyników, potrzebuje podzielić je na podstrony w php. Coś jak w MySQL
a na następnej podstronie
Jak coś takiego zrobić na oracle, słyszałem coś o FETCH, ale nie wiem z czym to sie je (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) Z góry dzięki za pomoc. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 740 Pomógł: 15 Dołączył: 23.08.2004 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
http://www.softax.pl/prywatne/marcink/pora...racle/968783673
edit Specjalnie dla Ciebie fragment dokumentacji Pagination with ROWNUM My all-time-favorite use of ROWNUM is pagination. In this case, I use ROWNUM to get rows N through M of a result set. The general form is as follows: Kod select * from ( select /*+ FIRST_ROWS(n) */ a.*, ROWNUM rnum from ( your_query_goes_here, with order by ) a where ROWNUM <= :MAX_ROW_TO_FETCH ) where rnum >= :MIN_ROW_TO_FETCH; where
One important thing about using this pagination query is that the ORDER BY statement should order by something unique. If what you are ordering by is not unique, you should add something to the end of the ORDER BY to make it so. If you sort 100 records by SALARY, for example, and they all have the same SALARY value, then specifying rows 20 to 25 does not really have any meaning. In order to see this, use a small table with lots of duplicated ID values: Kod SQL> create table t 2 as 3 select mod(level,5) id, trunc(dbms_random.value(1,100)) data 4 from dual 5 connect by level <= 10000; Table created. And then query rows 148 to 150 and 151 after sorting by the ID column: Kod SQL> select * 2 from 3 (select a.*, rownum rnum 4 from 5 (select id, data 6 from t 7 order by id) a 8 where rownum <= 150 9 ) 10 where rnum >= 148; Kod ID DATA RNUM
------- ---------- ----------- 0 38 148 0 64 149 0 53 150 Ten post edytował bigZbig 17.10.2006, 13:48:41 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 8.10.2025 - 00:07 |