Re: Select Database number & show it

From: Date: Thu, 29 Mar 2001 16:33:43 +0000
Subject: Re: Select Database number & show it
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7998@lists.php.net to get a copy of this message
On Thu, Mar 29, 2001 at 05:07:43PM +0200, Mirko Cegledi wrote: > > I believe this is what you want: > > > > SELECT * FROM mydatabase LIMIT 0,5 > > I'm for this for months now. But seems not to work with Oracle 8.0.5. Could > anybody tell me how I get the first five rows of a table with oracle? The solution mentioned above is mySQL only - sorry. You can use this on Oracle since 8.1 (rather slow): SELECT * FROM (SELECT ROWNUM rownum2, inline_view1.* FROM (SELECT ROWNUM rownum1, ename, hiredate FROM emp ORDER BY hiredate ) inline_view1 ) inline_view2 WHERE rownum2 BETWEEN 5 AND 7 Since 8.1.6 you may use: SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY hiredate) rownum1, ename, hiredate FROM emp ) inline_view1 WHERE rownum1 BETWEEN 5 AND 7 If you just want to get n lines: SELECT * FROM (SELECT ename, hiredate FROM emp ORDER BY hiredate) WHERE ROWNUM < n This all taken from http://www.koehntopp.de/php/faq-database_oracle.html#database_oracle-10 and provided as is. If you know some german, that page is worth a lot! Regards, Karsten -- fishfarm - Karsten Dambekalns Echternstr. 73 - 38100 Braunschweig Tel. +49 531 1232902 mailto:k.dambekalns@fishfarm.de Fax. +49 531 1232906 http://www.fishfarm.de/ -----------------------------------------------------

« previous php.db (#7998) next »