<!--
把第一个and变成where
keywords作用于sn和name字段
-->
<sql id="whereSql">
<where>
<if test="keywords!=null and keywords!=''">
and (
d.sn like concat('%',#{keywords},'%') or
d.name like concat('%',#{keywords},'%'))
</if>
</where>
</sql>
<!--要想做分页就要实现两条sql-->
<!--Long querryCount(BaseQuery query);-->
<select id="querryCount" parameterType="DepartmentQuery" resultType="long">
select count(*) from t_department d
<include refid="whereSql"/>
</select>
<!--List<T> queryData(BaseQuery query);
要查询关联对象信息
三个多对一嵌套结果 1条sql手动封装
-->
<select id="queryData" parameterType="DepartmentQuery"
resultMap="DepartmentMap">
【多对一】mapper.xml的关联查询
最新推荐文章于 2023-02-27 22:43:59 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)