------解决方案-------------------- String sql = "select top "+pageSize+" * from loginUser where id not in(select top "+pageSize*(pageIndex-1)+" id from loginUser where sex='男' and toupiaoTF=1 order by piaoshu desc) and sex='男' and toupiaoTF=1 order by piaoshu desc";
------解决方案-------------------- 其实本质上就是个“减法”,楼主你先理解这个概念,然后试试看吧: Select Top :pageSize * From loginUser Where id Not In ( Select Top (:pageIndex * (:pageSize - 1)) id From loginUser Where sex='男' And toupiaoTF=1 Order By piaoshu Desc ) And sex='男' And toupiaoTF=1 Order By piaoshu Desc
分段试一试,比如先试试看: select top (5*(2-1)) id from loginUser where sex='女' and toupiaoTF=1 order by piaoshu desc
然后才全部加上: select top 5 * from loginUser where id not in ( select top (5*(2-1)) id from loginUser where sex='女' and toupiaoTF=1 order by piaoshu desc ) and sex='女' and toupiaoTF=1 order by piaoshu desc