mysql的union all值相加

//查看帖子品论数:所有审核通过评论数+自己未审核和不通过评论
@Query(value = "select sum(comment.cou) from (" +
        "select count(*) cou from post_comment where del_flag='0' and post_id=?1 and audit_flag='1' " +
        "union all " +
        "select count(*) cou from post_comment where del_flag='0' and post_id=?1 and customer_id=?2 and audit_flag in ('0','2')) comment ",nativeQuery = true)
Integer getCommentCount(String postId,String customerId);

猜你喜欢

转载自blog.csdn.net/weixin_39936341/article/details/83956960
今日推荐