Bob,
 
I just thought I would add another thing here for you before it comes up.
 
There is no native LIMIT (MySQL) clause in Oracle.  However you can
mimic the behaviour of the LIMIT with a nested query.  The simplest
way to do this is if your Oracle install has OLAP functionality.  Then
the query will look something like:
 
SELECT *
  FROM (SELECT col_a,
               col_b,
               col_c,
               ROW_NUMBER() OVER (ORDER BY UPPER(col_a) ASC) AS rn
          FROM a_table
 WHERE rn BETWEEN <lower_val> AND <upper_val>
  
The "ROW_NUMBER() OVER (ORDER BY UPPER(col_a) ASC) AS rn" will force
the database to pre-order the resultset before it applies the row
numbers.  Which is obviously rather important to getting the numbers
in the correct order.

If your database does not have OLAP, then it will take a triple-nested
SELECT that would look something like:

SELECT *
  FROM (SELECT inn.*, 
               ROWNUM rn
          FROM (SELECT col_a,
                       col_b,
                       col_c
                  FROM a_table
                 WHERE col_a = x
                 ORDER BY col_a) inn
        ) outt
 WHERE rn BETWEEN <lower_val> AND <upper_val>

Running a SELECT in this manner will apply the ORDER BY clause before
the rownumers are assigned.  If you don't need an ORDER BY, then you
can remove one layer of nesting.

SELECT *
  FROM (SELECT col_a,
               col_b,
               col_c,
               ROWNUM AS rn
          FROM a_table
 WHERE rn BETWEEN <lower_val> AND <upper_val>

 
Hope you find this useful.
 
Cheers,
Keith.






Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to