码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis处理一对多的查询

时间:2016-12-24 02:23:58      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:mybatis   teacher   each   for   form   嵌套   学生   sel   bsp   

//查询出某个班级对应的所有老师和学生

1、使用嵌套结果

select * from classes c,teacher t,student s where c.teacher_id = t.t_id and c.c_id = s.class_id where c_id = #{id}

2、使用嵌套查询

select * from classes where c_id = #{id};

select * form teacher where t_id = #{id}

select * from student where class_id = #{id}

 

mybatis处理一对多的查询

标签:mybatis   teacher   each   for   form   嵌套   学生   sel   bsp   

原文地址:http://www.cnblogs.com/hy87/p/6216535.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!