LEFT JOIN applet_book_score_tag b ON a.id = b.score_id
LEFT JOIN applet_book_score_sub_tag c ON b.id = c.tag_id
) t1
LEFT JOIN applet_book_user_score t2 ON t1.tagId = t2.score_tag_id
AND IFNULL( t1.subId, 0 ) = IFNULL( t2.sub_tag_id, 0 )
GROUP BY
t1.`scoreName`,
t1.`tagName`,
t1.`subTagName`
</select>
<deleteid="deleteChosen">
DELETE FROM
applet_book_user_score
WHERE
score_tag_id IN ( SELECT id FROM applet_book_score_tag WHERE score_id NOT IN ( SELECT DISTINCT score_id FROM applet_book_score_tag WHERE id = #{scoreTagId,jdbcType=BIGINT} ) )
AND wechat_user_id = #{wechatUserId,jdbcType=BIGINT}
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and adviser_id = #{adviserId,jdbcType=BIGINT}
</delete>
<deleteid="deleteChosenTag">
DELETE FROM
applet_book_user_score
WHERE
score_tag_id != #{scoreTagId,jdbcType=BIGINT}
AND wechat_user_id = #{wechatUserId,jdbcType=BIGINT}