Is there a way to make an Oracle
query behave like it contains a MySQL limit
clause?
In MySQL
, I can do this:
As I explained in this article, since version 12c Oracle supports the SQL:2008 Standard, which provides the following syntax to limit the SQL result set:
SELECT
title
FROM
post
ORDER BY
id DESC
FETCH FIRST 50 ROWS ONLY
Prior to version 12c, to fetch the Top-N records, you had to use a derived table and the ROWNUM pseudocolumn:
SELECT *
FROM (
SELECT
title
FROM
post
ORDER BY
id DESC
)
WHERE ROWNUM <= 50