1、使用嵌套结果方式
sql语句:select c.* ,t.t_name from class c,teacher t where c.teacher_id = t.t_id where c.c_id = #{id}
<resultMap>
<id property="" column=""/>
<result property="" column=""/>
<association property="teacher" javaType="Teacher">
<association>
</resultMap>
2、使用嵌套查询方式
select * from class where c_id = #{id}
select * from teacher where t_id = #{teacher_id} //使用上一个查询的结果teacher_id
<resultMap>
<id property="" column=""/>
<result property="" column=""/>
<association property="teacher" column="teacher_id" select="getTeacher">
<association>
</resultMap>
时间: 2024-12-28 06:11:56