|
|
|
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;
|
|
| normalize fields and strings used in where (command's Sql) Categories : PHP, Databases, Oracle, Functions | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | Installing Oracle support to PHP running in Apache Categories : PHP Configuration, Apache, Oracle, Databases, Web Servers | | | StoredProcedure, Stored Procedure, Oracle, OCI8, OCI8i Categories : OCI8, Oracle, Databases, PHP | | | Connecting to Oracle with php3 Categories : Oracle, PHP, Databases | | | Simple class for accessing databases like MSSql Server, Oracle etc by Raju Categories : PHP, MS SQL Server, Databases, PHP Classes, 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 | | | 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 | | | PHP CLASS for ORACLE (database connectivity) Categories : PHP, PHP Classes, Classes and Objects, Databases, Oracle | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | PhpIBadmin - Web interface to Interbase RBDMS , this is a port of
phpMyadmin Categories : Databases, InterBase, PHP | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | |
| | | | 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
| |
|
|
|