Hello All,
Can you please guide me to the equivalent to this query in Oracle:
SELECT SQL_CALC_FOUND_ROWS * FROM tableName
SELECT FOUND_ROWS() as cnt
Thanks
Hello All,
Can you please guide me to the equivalent to this query in Oracle:
SELECT SQL_CALC_FOUND_ROWS * FROM tableName
SELECT FOUND_ROWS() as cnt
Thanks
The query retrieves all rows from tableName
, and then retrieves the number of rows in tableName
. Doing that with SQL_CALC_FOUND_ROWS
is just a performance optimization: it saves you from doing two queries.
If performance is not an issue, an equivalent for Oracle would be:
SELECT * FROM tableName
SELECT count(*) from tableName
If you are in a position to rewrite the client, you could do both in one query:
SELECT *
, (SELECT count(*) from tableName) as totalRows
FROM tableName
For Oracle 9i+, use:
SELECT COUNT(*) over () found_rows,
t.*
FROM TABLE t
Be aware that it is faster to run separate queries than to use SQL_CALC_ROUND_ROWS in MySQL.