SELECT TOP 10 *
FROM (select a.*,b.typename from 表1 a left join 表2 b on a.typeid=b.typeid) a
WHERE ID >(SELECT MAX(id) FROM (SELECT TOP 20 id FROM 表1 ORDER BY id) b)
ORDER BY ID
sql server:
前10条:
select top 10 * from 表 order by 需要排序的字段
11-20:
select * from
(select row_number() over (order by 需要排序的字段) as id,* from 表
)a
where id between 11 and 20
或者
select top 10 * from 表
where id not in (select top 10 * from 表 order by 需要排序的字段)
order by 需要排序的字段
oracle:
前10条:
select * from
(
select * from 表 order by 需要排序的字段
)
where rownum<=10
11-20:
select * from
(
select * from 表 order by 需要排序的字段
)
where rownum between 11 and 20
mysql:
前10条
select * from
(
select * from 表 order by 需要排序的字段
)a
limit 10
11-20条:
select * from
(
select * from 表 order by 需要排序的字段
)a
limit 11,10
---------
根据你的要求
将上面
from 表
替换为
from (select a.*,b.typename from 表1 a left join 表2 b on a.typeid=b.typeid) a
就可以了
select * from (select *,row_number() over(order by c.id) tid from (select a.*,typename from tbl1 a,tbl2 b where a.typeid = b.typeid) c) where c.tid between 11 and 20
select
top 10 * from (select b.*,c.typename from b left join c on b.typeid=c.typeid) b where id >(select id from (select top 20 id FROM b order by id) c)order by id