<select id="findUser3" resultMap="usermap">
select
a.id as user_id,
a.name as user_name,
a.sex as user_sex,
a.age as user_age
from T_User a where a.age=20
<if test="name!=null">
AND a.name=#{name}
</if>
</select>
<select id="findUser4" resultMap="usermap">
select
a.id as user_id,
a.name as user_name,
a.sex as user_sex,
a.age as user_age
from T_User a
<where>
<if test="name!=null">
a.name=#{name}
</if>
<if test="fname!=null">
AND a.fname=#{fname}
</if>
</where>
</select>
<select id="findUserByIds" resultMap="usermap">
select
a.id as user_id,
a.name as user_name,
a.sex as user_sex,
a.age as user_age
from T_User a where a.id in
<foreach collection="list" index="index" item="item"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>