有些重复次数太多的sql语句,如果每次都写,显得过于麻烦与臃肿,我们可以通过<sql>完成语句的声明,通过<include> 标签进行应用拼接
<!-- <sql>抽离重复代码 <include>进行引用拼接-->
<sql id="findAllStudentsql">
select * from student_tb
</sql>
<select id="findAllStudent" resultType="Student">
<include refid="findAllStudentsql"></include> where id >40
</select>