Re: number of rows returned
| From: | Mike Hanney | Date: | Wed, 02 Aug 2000 12:08:18 +0000 |
| Subject: | Re: number of rows returned | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1710@lists.php.net to get a copy of this message | ||
Hi,
You might be able to put the order in a sub select.
undesired:
select first_name
from staff_tbl
where rownum <= 4
order by first_name desc;
desired:
select first_name
from (select first_name
from staff_tbl
order by first_name desc)
where rownum <= 4;
Not sure about returning rows 4 to 6 though as Oracle will stop retrieving records if you try rownum => 4 and rownum <= 6, stops at row 4, I think.
Amazes me too that there is no LIMIT funtion in Oracle.
Mike.
At 12:59 02/08/00 +0200, Pedro Garre wrote:
Hi, I want to get only the first 4 rows from a query. The query is complex, and has an order by statement. Oracle documentation states that ROWNUM is assigned before rows are sorted, so I understand that this will _not_ work as desired: select ... from ... where ... and ROWNUM < 4 order by ... In Postgresql you just need to include "LIMIT 4". I also want to retrieve rows 4 to 6, but no clue how to do it. In Postgresql is as easy as "LIMIT 4,3" (or something similar). Anybody knows how to do that with Oracle (the most expensive database in the world) ? Thanks in advance, Pedro. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net