INSERT INTO post_vote (post_id, member_id, vote_type, created_at) VALUES (#{postId}, #{memberId}, #{type}, NOW()) ON DUPLICATE KEY UPDATE vote_type = #{type}, created_at = NOW() DELETE FROM post_vote WHERE post_id = #{postId} AND member_id = #{memberId} DELETE FROM post_vote WHERE post_id = #{postId} INSERT INTO comment_vote (comment_id, member_id, vote_type, created_at) VALUES (#{commentId}, #{memberId}, #{type}, NOW()) ON DUPLICATE KEY UPDATE vote_type = #{type}, created_at = NOW() DELETE FROM comment_vote WHERE comment_id = #{commentId} AND member_id = #{memberId} DELETE FROM comment_vote WHERE comment_id = #{commentId} DELETE FROM comment_vote WHERE comment_id IN (SELECT id FROM comment WHERE post_id = #{postId})