SQL多表查询

SQL多表查询

多表查询

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
喜欢就支持一下吧
点赞6 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容