映射文件里的sql语句
<select id="selectByTerm" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from projects,projectstype,user
<trim prefix="where" prefixOverrides="and|or">
ps_pst_id=pst_id and ps_us_id=us_id
<if test="psName!=null and psName!=''">
and ps_name=#{psName}
</if>
<if test="usName!=null and usName!=''">
and us_name=#{usName}
</if>
<if test="psType!=null and psType!=''">
and ps_type=#{psType}
</if>
<if test="pstName!=null and pstName!=''">
and pst_name=#{pstName}
</if>
</trim>
</select>
注意:
1.ResultMap要重写一个联表的
2.Base_Column_List要重写一个你要查询的列名
3.联表条件要放在trim标签内第一行,其它动态条件写在if标签内