以下假设表名为A
一、SQL Server
解法一:
select top 10 * from A where ID not in (select top 30 ID from A)
解法二:
select top 10 * from (select top 40 ID from A order by ID) as a order by a.ID desc
解法三:
select * from(select *,ROW_NUMBER() over(order by ID)as ‘userID’ from A) as a where a.userID between 31 and 40
二、MYSQL
select * from A limite 30,10
三、Oracle
SELECT * FROM A WHERE ROWNUM <= 40 and ROWNUM>30;
查询数据库表中的30到40条数据(id不连续)
最新推荐文章于 2022-02-01 19:36:23 发布