mybatis--Mybatis-动态SQL-sql&include
This commit is contained in:
@@ -4,9 +4,14 @@
|
||||
"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},'%')
|
||||
|
||||
Reference in New Issue
Block a user