需求: 查询 `animal `表姓名像“狗”的同学的姓名、年龄、班级名称(从`class_table`中获取,其中`class_table`.id = `animal`.id)
Mapper层:
/**
* String WRAPPER = "ew";
* @param wrapper
* @return
*/
List<Animal> selectAnimals(@Param(Constants.WRAPPER) Wrapper<Animal> wrapper);
selectAnimals方法的xml:
<select id="selectAnimals" resultType="com.zhang.entity.Animal">
SELECT animal.`name`,animal.`age`,ct.`class_name`
FROM `animal` animal LEFT JOIN `class_table` AS ct
ON animal.`class_id` = ct.`id`
<where>
${ew.sqlSegment}
</where>
</select>
注意:此处要使用where标签