<selectid="selectByMoney"resultType="demo.entity.User">
select * from t_user
<where><iftest="money != null and money != ''">
and money>1000
</if></where></select>
二、foreach标签
<selectid="selectUserByIds"resultType="demo.entity.User">
select * from t_user
<where><foreachcollection="ids"open="and id in("item="id"separator=","close=")">
#{id}
</foreach></where></select>
三、sql标签
<sqlid="sql_temp">
select id ,user_name, passwd, money from t_user
</sql>
<selectid="login"resultType="demo.entity.User"><includerefid="sql_temp"></include> where user_name=#{userName} and passwd=#{passwd}
</select>