<!--这里的#{id}参数就是collection中定义的column字段-->
<select id="querytemplatebyid" parametertype="java.lang.integer" resultmap="template">
select id pt_id, title pt_title
from t_activity_template where is_delete=0 and activity_id = #{id}
order by sort_number desc
</select>
<select id="querybypage" parametertype="com.xx.oo.activitypagerequest" resultmap="richresultmap">
select t.*,t1.real_name creator_name
from t_activity t
left join user t1 on t1.user_id = t.creator
<where>
t.is_delete = 0
<if test="criteria != null and criteria.length()>0">and (t.activity_name like concat("%",#{criteria},"%"))</if>
</where>
order by t.id desc
</select>
不需要分页的普通查询,使用resultmap
<select id="querybyid" parametertype="java.lang.integer" resultmap="resultmap">
select t.*, t6.id pt_id, t1.title pt_title
from t_activity t
left join t_activity_template t1 on t.id=t6.activity_id and t1.is_delete=0
where t.is_delete = 0 and t.id = #{id}
</select>