我是小酱油啊 2019-11-21 19:56 采纳率: 0%
浏览 220

mybatis两表连接查时,为什么必须要查主表id才能拿出数据,不然只返回第一条数据,那个大佬知道原理是什么??

<resultMap type="cn.kgc.tangcco.hsl.pojo.Student1" id="ss">
        <id property="sid" column="sid"/>
        <result property="sage" column="sage" />
        <result property="sname" column="sname"/>
        <result property="gender" column="gender"/>
        <result property="xuefen" column="xuefen"/>
        <result property="pwd" column="pwd"/>
        <result property="team" column="team"/>
        <result property="role" column="role"/>
        <result property="status" column="status"/>

        <association property="score" javaType="cn.kgc.tangcco.hsl.pojo.Score">         
            <result property="bishi" column="bishi"/>
            <result property="jishi" column="jishi"/>           
            <result property="zong" column="zong"/>         
        </association>      
    </resultMap>
<!--不写s.sid时只返回第一条记录-->
<select id="selectall" resultMap="ss">
        select s.sid,s.sname,s.sage,s.team,s.role,ss.zong from students_copy s LEFT join score ss on  s.sid = ss.sid
    </select>





  • 写回答

1条回答 默认 最新

  • Kwan的解忧杂货铺 Java领域优质创作者 2024-01-27 19:36
    关注

    是不是用了distinct或者group by?

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题