基于sql Server数据库的分页模糊查询
今天正好有个下拉框因为数据过多需要进行数据分页+模糊搜索
我用的是sql Server2012版本的数据库,所以支持offset分页写法,别的小伙伴需要根据自己的数据库版本进行调整
话不多说上代码
<select id ="getdfzdmc" resultType= "java.util.Map" >
select id,bh,mc,icdbh,pyjm from jcxx_zdmc
<where >
<if test = "zdm ==null ">
and sybz =1 order by id
offset ((#{pageIndex}- 1)* 100) rows
fetch next 100 rows only;
</if>
</where>
<where>
<if test="zdm!=null">
zdmc like '%' + #{zdm} + '%' and sybz = 1
order by id
offset ((#{pageIndex}- 1)* 100) rows
fetch next 100 rows only;
</if>
</where>
</select >
转载的话记得声明哦