[42000][923] ORA-00923: required FROM keyword not found

When writing a paging query in the Oracle database, an error occurs when using rownum.

Code:

SELECT *
 FROM (
    SELECT *, ROWNUM AS rnum
     FROM test t
)
WHERE rnum BETWEEN 1 AND 5;

Error reported:

[42000][923] ORA-00923: 未找到要求的 FROM 关键字 Position: 31

problem causes:

The * in the subquery does not specify the table name to which it belongs, so it should be changed to t.*

Modified code

SELECT *
 FROM (
    SELECT *, ROWNUM AS rnum
     FROM test t
)
WHERE rnum BETWEEN 1 AND 5;

execution succeed:

Guess you like

Origin blog.csdn.net/qq_51118755/article/details/133815927