我陷入了MySQL查询。我得到了太多的结果。
SELECT
un.user_uid,
un.notification_date,
un.notification_text,
un.notification_type,
un.post_id,
up.user_uid AS notification_user_uid,
uu.user_username
FROM user_notifications un
LEFT JOIN
user_posts_comments up
ON
up.post_id = un.post_id
LEFT JOIN
user_user uu
ON
up.user_uid = uu.user_uid
WHERE
un.notification_status = 1 AND
un.user_uid = 'GSfbDYTBH2PzECFeyxGrVJ0bJ' ORDER BY
un.notification_date DESC
我有一个包含post_id的表UN,我在UP中查找相同的post_id并获得user_uid,然后在UU表中查找user_username。但是这样我得到了重复的结果(我知道原因,但不知道如何解决它)。
这是我需要的结果
这些是我的桌子