查询主表:<resultMaptype="com.demo.bean.WXGameRankingBean" id="weiboJoinAccountResultMap"> <id property="id" column="id" /> <result property="score" column="score" /> <result property="openid" column="openid" /> <result property="createTime" column="create_time" /> <result property="gameid" column="gameid" /> <result property="subscribe" column="subscribe" /> <association property="device" column="dp_id" javaType="com.demo.bean.DeviceBean" resultMap="joinAccountResult" /> <id property="dpId" column="dp_id" />type="com.demo.bean.DeviceBean" id="joinAccountResult"><resultMapTo associate table data:</resultMap>
<id property="openId" column="openid" /></resultMap>
<!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> 查询语句:<selectid="getDeviceAndRankingByGameid" resultMap="weiboJoinAccountResultMap" parameterType="java.util.HashMap"> select rr.id as id,rr.score as score,rr.openid as openid,rr.create_time as createTime, rr.gameid as gameid,rr.subscribe as subscribe,dd.* from wx_game_ranking rr left outer join zqw_device dd on rr.openid = dd.openid where rr.openid = dd.openid and rr.gameid=#{gameid} and rr.subscribe=#{subscribe} group by rr.openid order by rr.score desc,rr.create_time asc <if test="limit != null"> ${limit} </if></select>