1.?<!--查詢id字段的最大值-->??
<select id="queryMaxId" resultType="Integer">??select COALESCE (Max(gid),0) as gid from t25175_grade??</select></mapper>
2.<!--批量刪除-->Boolean deleteMany(String[] str);
<delete id="deleteMany">? ? delete from t25175_student where studentid in
<foreach collection="array" item="studentid" open="(" separator="," close=")">? ? ? ? #{studentid}
</foreach></delete>
3.<!--多條件框模糊查詢-->
<select id="findLike" resultMap="BaseResultMap">? ? select* from t25175_student
<where>? ? ? ? <!--添加if條件如果參數(shù)為空則不拼接sql-->
? ? ? ? <if test="studentid != null and studentid != '' ">? ? ? ? ? ? studentid like concat('%',#{studentid},'%')
? ? ? ? </if>? ? ? ? <if test="gid != null and gid != '' ">? ? ? ? ? ? and gid like concat('%',#{gid},'%')
? ? ? ? </if>? ? ? ? <if test="cid != null and cid.size > 0 ">? ? ? ? ? ? and cid in
<foreach item="cid" index="index" collection="cid"
? ? ? ? ? ? ? ? ? ? open="(" separator="," close=" )">#{cid}
? ? ? ? ? ? </foreach>? ? ? ? </if>? ? ? ?
? ? </where>order by studentid
</select>
4.<!--根據(jù)grade和studenclass查找所有的學(xué)生信息-->
<select id="selectAllByStudentclass"? resultMap="BaseResultMap">? ? select* from t25175_student
<where>? ? ? ? <foreach item="grade" index="index" collection="grade"
? ? ? ? ? ? ? ? separator="or">? ? ? ? <foreach item="studentclass" index="index" collection="studentclass"
? ? ? ? ? ? ? ? ? separator="or" >? ? ? ? (grade=#{grade} and studentclass=#{studentclass})
</foreach>? ? ? ? </foreach>? ? </where></select>
5.<!--根據(jù)cid查找所有的學(xué)生信息-->
<select id="selectAllByCid" parameterType="java.util.List"? resultMap="BaseResultMap">? ? select* from t25175_student
<where>cid in
<foreach item="cid" index="index" collection="list"
? ? ? ? ? ? open="(" separator="," close=" )">#{cid}
? ? </foreach></where></select>