1.Spring-mybatis-动态SQL-sql&include标签

This commit is contained in:
2025-09-26 15:29:02 +08:00
parent 9cb8722bd4
commit 1acde5501e

View File

@@ -3,9 +3,14 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd"> "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inmind.mapper.EmpMapper"> <mapper namespace="com.inmind.mapper.EmpMapper">
<!--抽取Sql片段:给需要使用Emp查询的sql进行复用include-refid-->
<sql id="commonEmpSelect">
select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time from emp
</sql>
<!--条件查询操作--> <!--条件查询操作-->
<select id="list" resultType="com.inmind.pojo.Emp"> <select id="list" resultType="com.inmind.pojo.Emp">
select * from emp <include refid="commonEmpSelect"></include>
<where> <where>
<if test="name != null"> <if test="name != null">
name like concat('%',#{name},'%') name like concat('%',#{name},'%')