javaEEday09-Mybatis-动态SQL-sql&include

This commit is contained in:
xx
2026-10-24 11:14:37 +08:00
parent 6cf5d2125f
commit 8dfa803845
@@ -3,10 +3,14 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inmind.mapper.EmpMapper">
<!--抽取公共的查询sql-->
<sql id="empCommonSelect">
select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time from emp
</sql>
<select id="list1" resultType="com.inmind.pojo.Emp"><!--注意:resultType定义的是单条记录的java封装类型-->
select * from emp
<!--插入指定的sql片段-->
<include refid="empCommonSelect"></include>
<where>
<if test="name != null">
name like concat('%',#{name},'%')