<select id="queryFinishedTaskInfo" resultMap="BaseResultMap" parameterType="java.util.Map"> select <include refid="Base_Column_List" /> from month_card_task_log <where> 1 = 1 <if test="member_id != null" > and active_code = #{memberId} </if> <if test="recordType != null" > and record_type = #{recordType} </if> <if test="dayId != null" > and day_id = #{dayId} </if> </where> and del_flag = 0 </select>
1 = 1是为了防止没传参数导致SQL异常:select * from month_card_task_log and del_flag = 0;
加上1=1,没传参数时:select * from month_card_task_log where 1 = 1 and del_flag = 0;