# 根据sn、mac分组,将sn相同的数据行中的user_id、button_number分别合并成一行,并以逗号隔开
SELECT b.sn,b.mac,b.model,GROUP_CONCAT(a.user_id) as userIds,GROUP_CONCAT(a.button_number) as buttonNumbers
FROM device_blood_pressure as b LEFT JOIN device_blood_pressure_bind a ON a.mac = b.mac
WHERE a.user_id in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach> GROUP BY b.sn,b.mac;
网友评论