Re: [rfc] Row limit support for Pear DB
| From: | Graeme Merrall | Date: | Wed, 31 Oct 2001 22:24:03 +0000 |
| Subject: | Re: [rfc] Row limit support for Pear DB | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-2496@lists.php.net to get a copy of this message | ||
Quoting Morgan Christiansson <morgan.christiansson@telia.com>:
> I THINK that oracle has something like this:
>
> SELECT * WHERE rownum BETWEEN ($from,$to)
>
> i'm not sure if oracle supports the BETWEEN syntax though but otherwise
>
> it would be
>
> SELECT * WHERE rownum <= $from AND rownum >= $to
>
> Although it was more than a year ago i used oracle, and i didn't use it
>
> very much. :)
>
I've been in a discussion on row sets in oracle as well as someone came up with
this one as well. The main problem was ordering because ROWNUM has precedence
over ORDER BY.
I've not tried the solution below using MINUS but I know I've used the
subselect method plenty of times to emulate LIMIT.
select * from
(select row1, row2,... from table_name order by row1)
where rowno < 31
MINUS
select * from
(select row1, row2,... from table_name order by row1)
where rowno < 20
Cheers,
Graeme