用户积分表:
用户信息表:
SQL:
查询用户个人积分排名信息:
select t.member_id memberId,t.rank,t.all_integral allIntegral,mi.name,mi.nickname,mi.headimg_url headimgUrl from (select m.member_id,m.all_integral, (@rowNum:=@rowNum+1) as rank
from integral_member m,
(Select (@rowNum :=0) ) b
order by m.all_integral DESC,m.modify_date) t left join member_info mi on t.member_id=mi.id where t.member_id=5
XML:
<!-- 查询用户个人积分排名信息 -->
<select id="queryMemberRank" parameterType="Integer" resultType="com.wxb.uplus.uplusmanager.integral.dto.IntegralMemberAndInfo">
select t.member_id memberId,t.rank,t.all_integral allIntegral,mi.name,mi.nickname,mi.headimg_url headimgUrl from (select m.member_id,m.all_integral, (@rowNum:=@rowNum+1) as rank
from integral_member m,
(Select (@rowNum :=0) ) b
order by m.all_integral DESC,m.modify_date) t left join member_info mi on t.member_id=mi.id where t.member_id=#{memberId}
</select>
结果: