Skip to content
Advertisement

How to split sql query results into new incremental tables

I am using the following code to create a HTML table which works great to produce a table ordered by position based on points. However, I would like to sub divide the results into different tables with incremental names. For example, the first 20 results will be Table 1, the next 20 records will be table 2 and so on. I need it to be dynamic because the total number of records will be different each time the query runs.

I would appreciate advice on the best way to achieve this. Thanks

Advertisement

Answer

Test this (for 20 rows per page/table):

PS. The points column values must be unique, if not then the order of the rows with the same value is unpredictable (in such case you may expand sorting expression for to provide uniqueness, for example, use ORDER BY points, id).


10.4.14-MariaDB – f1inshot

Your query should be

and respectively

And the same – if ponts is not unique use expanded ORDER BY in window definitions.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement