#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    Return certain number of rows from Oracle.


    Is there a way to start at an only return a certain number of rows from an Oracle table using PHP, I've accomplished this in another scripting language(Net.Data) where you can set the starting row and the total number of rows to return.

    for example: starting row = 1 total rows = 11 returns the first eleven rows for an sql statement, then starting row = 12 total rows = 11 would return the next eleven and so on.

    thanks
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,188
    Rep Power
    2265
    Moved to the Oracle forum.
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
  4. #3
  5. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    539
    You can either:
    - Use a stored procedure
    - Use rownum to limit the number of records returned

    In the second case you should run a select count before the real query to retrieve the total number of rows returned.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    12
    Please try:

    select table_name, n from (
    select table_name, rownum n from (
    select table_name from all_tables
    order by table_name)
    ) where n >= 2 and n <= 4


    Cheers,
    Dan
    Last edited by Dan Drillich; October 3rd, 2003 at 03:51 PM.

IMN logo majestic logo threadwatch logo seochat tools logo