根据商铺shopId查询用户tb_users得到多个用户的u_id来查询其它结果 <select id="selectStudentsStatisticalVoList" parameterType="integer" >/*parameterType="com.ruoyi.goods.entity.vo.StudentsStatisticalVo"*/ select tus.user_name, tus.user_avatar, td.name, (select count(*) from tb_study_goods where tus.shop_id = sg.shop_id and tus.u_id = sg.u_id) as studyFor, /*count(case when is_complete = 1 then 1 else null end ) as finishNum,*/ (select count(*) from tb_study_goods where tus.shop_id = sg.shop_id and tus.u_id = sg.u_id and sg.is_complete = 1) as finishNum, (select sum (study_length) from tb_study_goods where tus.shop_id = sg.shop_id and tus.u_id = sg.u_id) as studyLength, (select count (*) from tb_chapter_goods_rela where tcgr.shop_id = tus.shop_id and tcgr.train_id = #{trainId}) as course, (select create_time from tb_study_goods where tus.shop_id = sg.shop_id and tus.u_id = sg.u_id order by create_time) as createTime from tb_users tus left join tb_study_goods sg on tus.shop_id = sg.shop_id and tus.u_id = sg.u_id left join tb_chapter_goods_rela tcgr on tcgr.shop_id = tus.shop_id and tcgr.train_id = #{trainId} left join tb_department td on td.department_id = tus.depart_id where tus.shop_id = #{shopId} </select>
加limit 1吧,就只返回一条了。
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632