|
|
|
Oracle SQL does not support anything like LIMIT in MySQL. You can just limit the
number of rows returned with rownum. So if you only want the first ten
records use:
SELECT * FROM table WHERE ROWNUM<10;
However the following won't work:
SELECT * FROM table WHERE ROWNUM>90 AND ROWNUM<100;
This is because Oracle checks for the first row and the condition is false,
as the rownum would be 1. So this row is not returned, thus the rownum is
still 0. So the rownum will never get to 90.
You can try :
SELECT * FROM table WHERE ROWNUM<101;
minus
SELECT * FROM table WHERE ROWNUM<91;
|
|
| Simple class for accessing databases like MSSql Server, Oracle etc by Raju Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle | | | normalize fields and strings used in where (command's Sql) Categories : PHP, Databases, Oracle, Functions | | | StoredProcedure, Stored Procedure, Oracle, OCI8, OCI8i Categories : OCI8, Oracle, Databases, PHP | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | PHP CLASS for ORACLE (database connectivity) Categories : PHP, PHP Classes, Classes and Objects, Databases, Oracle | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Installing Oracle support to PHP running in Apache Categories : PHP Configuration, Apache, Oracle, Databases, Web Servers | | | Connecting to Oracle with php3 Categories : Oracle, PHP, Databases | | | A database abstraction layer for the PHP Oracle 8 module (available from PHP 3.0.5). It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface. Categories : Databases, Oracle, PHP, Arrays, Variables | | | Paginator - a class that can help you to split MySQL database query result sets to pages. Categories : MySQL, Databases, HTML, PHP | | | EMS MySQL Manager - A Powerful MySQL Administration and Development Tool for Win32. Categories : Complete Programs, MySQL, Databases, Utilities, Windows 2000 | | | A template script to provide the ability to get the next or previous n records from a MySQL database. Categories : Databases, PHP, MySQL | | | Simple class to create insert and update statements. Independent of the access to the database. Makes handling complex inserts easier - especially when the table structure is liable to change. Categories : Databases, PHP Classes, PHP | | | Password reminder Categories : PHP, PHP Classes, Databases, MySQL, Mail | | | mod_auth_mysql - mod_auth_mysql was written in order to
allow users to use the blazing quick speed of MySQL in
order to store authentication information for their apache
web servers. Categories : Authentication, MySQL, Databases | |
| | | | Enrico Faccin wrote : 321
You can limit the search on both side with this
nested query:
SELECT * FROM (
SELECT *, ROWNUM
FROM mytable
WHERE myconditions
) WHERE ROWNUM>xx AND ROWNUM<yy;
| | | | Marcelo Toledo wrote : 614
If I do something like: select * from (select aaa, bbb, ROWNUM as X from table where aaa=bbb order by aaa desc) where X = 2;
If I want to get the second row returned this will not work as expected. Look why:
DATA_ENTRADA ROWNUM
------------------- ----------
16/05/2001 12:57:08 32 <- this is the firt row
16/05/2001 11:51:45 31 <- second
15/05/2001 18:05:53 30
15/05/2001 18:04:47 29
15/05/2001 18:04:10 28
So, to get the real row number in this case you will have to make 3 selects. For example:
select * from (select a, ROWNUM as X from (select a from table where ... order by ...)) where X = 2;
| | | | Marcelo Toledo wrote : 615
If I do something like: select * from (select aaa, bbb, ROWNUM as X from table where aaa=bbb order by aaa desc) where X = 2;
If I want to get the second row returned this will not work as expected. Look why:
DATA_ENTRADA ROWNUM
------------------- ----------
16/05/2001 12:57:08 32 <- this is the firt row
16/05/2001 11:51:45 31 <- second
15/05/2001 18:05:53 30
15/05/2001 18:04:47 29
15/05/2001 18:04:10 28
So, to get the real row number in this case you will have to make 3 selects. For example:
select * from (select a, ROWNUM as X from (select a from table where ... order by ...)) where X = 2;
| | | | Didier Berard wrote :1056
Hier is a full example for the limitation:
select * from (select a, b, c, rownum as limit from mytable where conditions order by whatiwant) where limit>x and limit <y;
with: whatiwant="a DES"C, x=3 and y=6
the result will be:
A B C LIMIT
--- --- --- ----------
30 1 2 4
29 2 2 5
Thanks to Enrico Faccin
| |
|
|