select * from (
select bo_id as board_id, bo_title as board_title, bo_cover_img as board_img, bo_hit as board_hit, bo_reply as board_reply, board_time, board_author, br_id as reply_id, br_content as reply_content, board_reply.created_at as reply_time, users_reply.u_nick as reply_nick, users_reply.u_idx as reply_u_id
from
board_reply
inner JOIN
(
select *, BB.created_at as board_time, u_nick as board_author from (
select *, 'community' as bo_type from board_community
UNION
select *, 'sportNews' as bo_type from board_sport_news
) as BB
INNER JOIN
users
on BB.bo_uid = users.u_idx
) as AA
ON br_bo_id = bo_id and bo_type = br_type
inner JOIN
users as users_reply
ON br_uid = users_reply.u_idx
where users_reply.u_idx = 8
) as CC
LEFT JOIN
(
select brl_br_id as like_reply_id, array_to_string(array_agg(brl_uid),',') as reply_likes from board_reply_like GROUP BY brl_br_id
) as LL
on like_reply_id = reply_id
LEFT JOIN
(
select bru_br_id as unlike_reply_id, array_to_string(array_agg(bru_uid),',') as reply_unlikes from board_reply_unlike GROUP BY bru_br_id
) as UL
on unlike_reply_id = reply_id
ORDER BY reply_id
offset 0
limit 10
pg board获取我的评论列表sql
最新推荐文章于 2024-11-15 00:00:40 发布