天天看點

mybatis連接配接mysql多表查詢_Mybatis實作多表聯合查詢

/p>

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

select a.id,a.name,b.class_name from student a,class b,

student_class c where a.id=c.sid and b.class_id = c.cid and a.name=#{name}

select * from student a,class b,

student_class c where a.id=c.sid and b.class_id = c.cid and a.name=#{name}

select * from class a left join student_class b on a.class_id=b.cid

left join student c on b.sid = c.id where a.class_id = #{class_id}