<!--sql抽取-->
<sql id="selectuser">
select * from user
</sql>
<!--动态if-->
<select id="fandByAll" parameterType="com.itheima.domain.User" resultType="com.itheima.domain.User">
<include refid="selectuser"></include>
<where>
<if test="id!=0">
and id =#{id}
</if>
<if test="username!=null">
and username =#{username}
</if>
<if test="password!=null">
and password =#{password}
</if>
</where>
</select>
<select id="fandById" parameterType="list" resultType="com.itheima.domain.User">
<include refid="selectuser"></include>
<where>
<foreach collection="list" open="id in (" close=")" separator="," item="id">
#{id}
</foreach>
</where>
</select> |
|