I want PHP paging to get data from SQL Server 2008,
1. mysql can limit n,m, SQL Server does not
2. To get the data of union after the page, see the useful rownum and top on the net, how to combine with union to realize it?
My result set is similar to
(select A,b,c,d from T1) union (select "As A, b,c,d from T2") Union (select A,b,c,d from T3)
Want to limit which bar of a result set is returned each time
Reply to discussion (solution)
Write this:
$sql = ' Your SQL query instruction '; $start = 1; Starting offset $pagesize = 20; Number of rows per page $sqls =<<< Sqlselect * FROM (SELECT a.*, ROWNUM RN from ($sql) A where ROWNUM < $start + $pagesize) where R N >= $startSQL;
$sqls is the final execution of the query statement
Understand, the original problem is that I do not know the results of the Union to take an individual name, thank you moderator ~ ~
Finally combined with Baidu I wrote this
SELECT * FROM ( select *, Row_number () Up (ORDER by A DESC) as RN from ($sql) as S1) as S2 where RN between $from and $to