新的面试题
JSP是怎么样实现分页的 问题点数:20、回复次数:8Top
1 楼yanxiazhiqiu(if the words don't come my way...)回复于 2005-11-01 12:02:53 得分 0
新的...
有两种解决方案,一种是第一次把所有的资料都查询出来,然后在每页中显示指定的资料;另一种是多次查询数据库,每次只获得本页的数据。建议第二种。Top
2 楼Croatia(Croatia)回复于 2005-11-01 12:53:50 得分 0
每次取需要的纪录,显示出来。Top
3 楼iamliming(lala)回复于 2005-11-01 17:27:21 得分 0
数据记录不多可以用取出所有数据。
记录多就要取本页的数据。Top
4 楼zealVampire(白鹤泉)回复于 2005-11-01 18:07:35 得分 0
未经过严格验证:
mysql:(10-20的记录)
select * from table order by column1 limit 10, 20
oracle:(这个sql可能会错,只是标明镶嵌的用法)
select * from (select table.*, rownum rnum from table order by table.id where rownum > 10 ) where rnum < 20
mssql:(不知道top n的写法能写出来不?
------------------------
至于其他使用ResultSet游标获取每叶数据的方法
可以看看jsp版本的 FAQTop
5 楼zealVampire(白鹤泉)回复于 2005-11-01 18:52:33 得分 0
mssql :
select top(10) * from table where id not in (select top 20 id from table order by column1)
---------
oracle 也可以使用select * from table where id not in (select id from table where rownum < 20) where rownum > 10
---------
其实原理都是一样的, 但是可能就是数据越多, 查询就越漫的。
可能用游标还快些, 或者叫人写好些的存储过程。Top
6 楼wb0622(波波)回复于 2005-11-01 19:26:21 得分 0
如果你的查询量不大,可以一次性的把数据查询出来,放在一个集合里,然后从集合里取数据进行分页.
如果你查询量大,建议从数据库里分批取出数据进行分页.Top
7 楼zealVampire(白鹤泉)回复于 2005-11-01 19:27:56 得分 0
oracle: 如果想前面翻业快些应该是先rownum < 20 再rownum > 10
------------->>是查询20到30的,可能写的会有点问题, 楼下的补充修改一下。
mssql :
select top(10) * from table where id not in (select top 20 id from table order by column1)
---------
oracle 也可以使用select * from table where id not in (select id from table where rownum < 20) where rownum > 10Top
8 楼vino_beer(吉胜利)回复于 2005-11-02 08:59:54 得分 0
题目怎么这么别扭, 各位的答案和JSP有什么关系?Top




