mssql中的分页查询

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Honnyee/article/details/85338052

mssql中的分页查询没有mysql那么方便,而且由于版本的原因,有些方法不通用,这里写一下比较通用的方法

使用top pageSize 处理,然后where 条件加上not in过滤不要的信息就好了

例如:

 <select id="getBugRecordList" resultType="XXXXXX">
    SELECT top ${pageSize} id,type,title,createTime from lyg_system_bugRecord
    WHERE name= #{name,jdbcType=VARCHAR}
    AND id not in (SELECT top ${index} id from tablename ORDER BY createTime DESC)
    ORDER BY createTime DESC;
  </select>

注意where有个条件是 not in 它里面的数据是一个语句生成的

猜你喜欢

转载自blog.csdn.net/Honnyee/article/details/85338052