我仍然对ROWNUM oracle函数感到困惑。
上次我在MySQL函数中使用LIMIT时是这样的:
$page -= 1;
$per_page = 3;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
$sql = ... WHERE ... LIMIT $start, $per_page;
但是现在如何在甲骨文中使用 ROWNUM?
$sql = ... WHERE ... ROWNUM $start, $per_page;
我使用它是因为我有分页页面。
任何人请指教。
在 Oracle 中,Rownum 值仅在查询的过滤阶段之后分配, 因此,您必须将其作为内联视图。 比如,
select *
from (select col1, col2, ROW_NUMBER() OVER(ORDER BY col1 ASC) RowNumber
FROM table)
where rownumber between 1 and 10
或
select *
from (select col1, col2, ROW_NUMBER() OVER(ORDER BY col1 ASC) RowNumber
FROM TABLE)
WHERE RowNumber > 1 AND RowNumber < 10;