1. 程式人生 > >MyBatis多條件查詢

MyBatis多條件查詢

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 &gt;= #{startTime} </if> <if test="endTime!=null"> and APPLY_TIME &lt;=#{endTime} </if> ORDER BY APPLY_TIME DESC </select>

注意的是”>”和“<”在MAPPER檔案中要用&gt;

&lt;代替