分页其实没有你想像的那么麻烦 写什么存储过程 直接sql语句就搞定了 查询10条到20条之间的关系 select * from 表名 where id not in (select id from 表名 where 。) 再加上你的top就可以了 不懂可以进我的群 QQ76208671
分页其实没有你想像的那么麻烦 写什么存储过程 直接sql语句就搞定了 查询10条到20条之间的关系 select * from 表名 where id not in (select id from 表名 where 。) 再加上你的top就可以了 不懂可以进我的群 QQ76208671
String sql="select top 20 * from TBL_reply where TOPICID="+topicId +" and topicid not in " + "(select top "+rowBegin+ " replyId from tbl_reply where topicid ="+topicId+" order by publishTime DESC) " + "order by publishtime DESC ";
/**
* 分页显示:得到某一页的List
* @param page 页码
* @return
*/
public static List getFenYeList(int page){
int rowBegin=0;
if(page>1){
rowBegin=PAGE_NUM*(page-1);
}
List<FoodInfo> list=new ArrayList<FoodInfo>();
String sql=String.format("select top(%d) * from foodInfo where foodID not in(select top(%d) foodID from foodInfo)",Service.PAGE_NUM,rowBegin);
// 调用DAO中的方法得到Result数据集
Result result=BaseDAO.runSelectSql(sql);
if(result.getRowCount()>0){
Map[] rows=result.getRows();
for(Map row:rows)
{
.........
list.add(..);
}
}
return list;
}
然后在页面中调用此方法
写分页面是有集中办法: 个人觉得 多添加一个字段来分页比较好 多条件查询:
注意尽量不要使用 distinct in 这些 可以 是用exsits来提高 查询 效率
写什么存储过程
直接sql语句就搞定了
查询10条到20条之间的关系
select * from 表名 where id not in (select id from 表名 where 。)
再加上你的top就可以了
不懂可以进我的群
QQ76208671
写什么存储过程
直接sql语句就搞定了
查询10条到20条之间的关系
select * from 表名 where id not in (select id from 表名 where 。)
再加上你的top就可以了
不懂可以进我的群
QQ76208671
+" and topicid not in " +
"(select top "+rowBegin+ " replyId from tbl_reply where topicid ="+topicId+" order by publishTime DESC) " +
"order by publishtime DESC ";