|
|
|
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 | | | 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 | |
| | 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 | | | Simple class for accessing databases like MSSql Server, Oracle etc by Raju Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle | | | Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0 Categories : PHP, Sessions, Databases, MySQL | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | | | Online Automatic Class Generator for MySQL Tables Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL | | | Modification of Shane Caraveo's guestbook. Uses ODBC...some code modifications Categories : ODBC, Databases, Complete Programs, PHP | | | php-gtk mysql querying tool Categories : PHP-GTK, MySQL, PHP, Databases | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | |
| | | | 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
| |
|
|