DB2 貌似没有mysql的limit语句支持,但可以通过嵌套查询实现,如:
SELECT * FROM(
SELECT B.*, ROWNUMBER() OVER() AS RN FROM
(
SELECT * FROM <TABLE_NAME>
) AS B
)AS A WHERE A.RN BETWEEN <START_NUMBER> AND <END_NUMBER>
通过rownumber函数,进行分页查找
DB2中没有专门的查第几条到第几条的SQL,但可以用其它的方法来实现,比如开窗函数,示例如下:SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY EMPNO) ID,T.* FROM EMPLOYEE T) WHERE ID BETWEEN 11 AND 20
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)