<selectid="selectByIF"resultType="com.zwei.domain.Event">
select * from event
/*where标签指定的是在SQL后拼接where条件,嵌套的IF来判断符合条件的拼接语句*/
<where><iftest="event_id != null and event_id != ''">
and event_id = #{event_id}
</if><!--使用choose标签来拼接一个排序语句,也可以使用if-->
order by event_desc
<choose><whentest="orderFlag!=null and orderFlag == 'desc'">
${orderFlag}
</when><otherwise>
asc
</otherwise></choose></where></select>