时间:2021-07-01 10:21:17 帮助过:31人阅读
一般项目从页面传递的数据是:page,pagesize;写成sql语句:
select * from (select rownum rn,a.* from A_MODEL a where rownum<=page*pageSize)aa where aa.rn>(page-1)*pageSize
下面是在实际项目的一条sql语句:值得注意的是在mybatis中不能用<,而要用转义字符(<)
<select id="queryLossModelList" resultMap="BaseResultMap"> SELECT aaa.*,s.MIN_NAME FROM (SELECT aa.* FROM (SELECT rownum rn,a.* FROM A_MODEL_LOSS a WHERE 1=1 <choose> <when test="cateId != null and cateId != ‘‘"> and a.model_cate_id in (select cate_id from a_category c where c.cate_id = #{cateId}) </when> <when test="brandId != null and brandId != ‘‘"> and a.model_cate_id in (select cate_id from a_category bc where bc.cate_parent_id = #{brandId}) </when> <when test="factoryId != null and factoryId != ‘‘"> and a.model_cate_id in (select cate_id from a_category bc where bc.cate_parent_id in (select cate_id from a_category fc where fc.cate_parent_id = #{factoryId})) </when> </choose> <if test="country != null and country != ‘‘"> and a.MODEL_COUNTRY = #{country} </if> <if test="standardName != null and standardName != ‘‘"> and a.MODEL_STANDARD_NAME LIKE ‘%${standardName}%‘ </if> <if test="vinNo != null and vinNo !=‘‘"> and a.MODEL_VIN_NO LIKE ‘%${vinNo}%‘ </if> and rownum <= #{endRow})aa WHERE aa.rn > #{startRow})aaa LEFT JOIN S_DICT_MIN s on aaa.MODEL_CLASS = s.MIN_VALUE </select>
Java中oracle分页查询01
标签:mybatis val dict inno aaa rownum creat 分页 country