首页 > 其他 > 详细

mybatis处理一对多的查询

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

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

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处理一对多的查询

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!