焦急在线等待:怎样实现"分页又分类"的SQL语句查询?! 谢谢!
//分页SQL如下:
select top pagesize * from dom_2_doclib where (SYS_DOCUMENTID not in (select top pagesize*currentpage SYS_DOCUMENTID from dom_2_doclib order by SYS_DOCUMENTID)) order by SYS_DOCUMENTID
//分类SQL如下:
select * from DOM_2_DOCLIB where SYS_DOCUMENTID in (select SYS_DOCUMENTID from DOM_REL_CAT where CLASS_ID=266) order by SYS_DOCUMENTID
现在我想把上面两个SQL语句的功能合二为一,也就是实现 "分页又分类 "的SQL语句,请问这条SQL语句该怎么写呢?
请SQL方面的好心行家帮帮我或者指点一下,项目紧张但我已经卡在这里了!
多谢!!!
------解决方案--------------------select top pagesize * from dom_2_doclib where (SYS_DOCUMENTID not in (select top pagesize*currentpage SYS_DOCUMENTID from
(
select * from DOM_2_DOCLIB where SYS_DOCUMENTID in (select SYS_DOCUMENTID from DOM_REL_CAT where CLASS_ID=266) order by SYS_DOCUMENTID
) temp
order by SYS_DOCUMENTID)) order by SYS_DOCUMENTID
------解决方案--------------------select top pagesize * from dom_2_doclib where (SYS_DOCUMENTID not in (select top pagesize*currentpage SYS_DOCUMENTID from dom_2_doclib order by SYS_DOCUMENTID) and SYS_DOCUMENTID in (select SYS_DOCUMENTID from DOM_REL_CAT where CLASS_ID=266)) order by SYS_DOCUMENTID
不过效率有点低
建议使用视图查询
------解决方案--------------------up