时间:2021-07-01 10:21:17 帮助过:27人阅读
(select A,B,C,D from t1) union (select '100' as A ,B,C,D from t2) union (select A,B,C,D from t3)
这样写:
$sql = '你的sql查询指令';$start = 1; //起始偏移$pagesize = 20; //每页行数$sqls =<<< SQLSELECT * FROM (SELECT A.*, ROWNUM RN FROM ($sql) A WHERE ROWNUM < $start+$pagesize)WHERE RN >= $startSQL;$sqls 就是最终执行的查询语句
理解了,原来我的问题在于 不知道给union 的结果取个别名,谢谢版主大人~~
最后结合百度 我是这样写的
SELECT * FROM ( SELECT * , ROW_NUMBER() OVER (ORDER BY A DESC) AS rn FROM ($sql) AS s1)AS s2 where rn between $from and $to