개발/mybatis
카테고리 및 검색 구현
issac
2021. 4. 8. 13:56
<!-- 검색전후 목록 페이징 -->
<select id="elist" resultType="e">
select * from (select rowNum rNum, emp_no, kor_name, jumin_nof, jumin_nob, sex, tech_lev,jop_type,desire_dept from
(select * from emp
<where>
<if test="genSelect == '' and techSelect == '' and jobSelect == ''">
<!-- 문자열 비교 -->
<if test="find_field == 'all'">
kor_name like #{find_name} or sex like #{find_name} or tech_lev like #{find_name}
</if>
<if test="find_field == 'kor_name'">
kor_name like #{find_name}
</if>
<if test="find_field == 'sex'">
sex like #{find_name}
</if>
<if test="find_field == 'tech_lev'">
tech_lev like #{find_name}
</if>
</if>
<!-- 카테고리 검색 -->
<if test="genSelect != null or techSelect != null or jobSelect != null">
<if test="genSelect != ''">
and sex = #{genSelect}
<if test="techSelect != ''">
and tech_lev = #{techSelect}
</if>
<if test="jobSelect != ''">
and jop_type = #{jobSelect}
</if>
</if>
<if test="techSelect != ''">
and tech_lev = #{techSelect}
<if test="genSelect != ''">
and sex = #{genSelect}
</if>
<if test="jobSelect != ''">
and jop_type = #{jobSelect}
</if>
</if>
<if test="jobSelect != ''">
and jop_type = #{jobSelect}
<if test="genSelect != ''">
and sex = #{genSelect}
</if>
<if test="techSelect != ''">
and tech_lev = #{techSelect}
</if>
</if>
</if>
</where>
order by emp_no desc)) where rNum >= #{startrow} and rNum <= #{endrow}
</select>
뭐하면 뭐가 걸리고 뭐하면 뭐가 안되고..
노가다 끝에 완성! 지금은 굴러만 가면되는게 목표