MyBatis多條件查詢
阿新 • • 發佈:2019-02-13
DAO:
List<LimitApply> selectInformationByOptions(Map<String, Object> map );
MAPPER:
<select id="selectInformationByOptions" resultMap="BaseResultMap" parameterType="java.util.HashMap">
select
<include refid="Base_Column_List" />
from TB_LIMIT_APPLY
where DEPARTMENT_ID = #{did}
and STATE =#{state}
<if test="startTime!=null">
and APPLY_TIME >= #{startTime}
</if>
<if test="endTime!=null">
and APPLY_TIME <=#{endTime}
</if>
ORDER BY APPLY_TIME DESC
</select>
注意的是”>”和“<”在MAPPER檔案中要用>
<
代替