c.name as categoryName,取别名是为了封装VO的时候能对应上,不然返回的结果有两个字段的名称都是name,会造成菜品分类无法匹配上
<selectid="pageQuery"resultType="com.sky.vo.DishVO">
select d.* , c.name as categoryName from dish as d left outer join category as c on d.category_id = c.id
<where><iftest="name != null">
and d.name like concat('%',#{name},'%')
</if><iftest="categoryId != null">
and d.category_id = #{categoryId}
</if><iftest="status != null">
and d.status = #{status}
</if></where>
order by d.create_time desc
</select>