多表查询
sql语句
select a.*,dmmb.name
from class_jcxx a left join class_ deleep dmmb on a.id = dmmb.id where a.id='abc';
动态SQL
<select id="getstudentList" resultMap="getstudent">
select a.id,a.name,a.age,a.sex,b.name,b.count from student a left join class b one a.class_id=b.id order
where a.id=#{id}
by student_id asc
</select>
<resultMap type="com.z4k.student" id="getstudent">
#单数据映射
<id coumn "id" property="classid"</>
<result column="class_name" property="className"/>
<result column="count" property="classCount"/>
<collection property="getList" ofType="cn.z4k.student">
<result column="name" property="name"/>
<result column="age" property="age"/>
<result column="sex" property="sex"/>
</collection>
</resultMap>
THE END
暂无评论内容