In the project test, the tester finds that when the query result list is displayed on multiple pages, some data is repeatedly displayed on several pages, and some are not displayed at one time. After analyzing the SQL, the original problem lies in the rownum paging. In Oracle, rownum is used for paging, Which is previously written as follows:
Select * from
(Select a. *, rownum rn from table a where condition) B
Where B. rn between 1 and 20;
When querying a single table, the results will not be displayed on the page, but when multiple tables are joined, rownum will be messy. Now we will change it to the following method: sort by specified fields and then get rownum, in this way, the results of each query are consistent:
Select * from
(Select a. *, rownum rn from
(Select * from table c, table1 d where condition order by c. id desc)
) B where B. rn between 1 and 20