1 回答

TA貢獻(xiàn)1906條經(jīng)驗(yàn) 獲得超10個(gè)贊
聽起來您想列出表users_post中給定用戶的所有記錄。如果這是正確的,這就是您的查詢應(yīng)該是這樣的:by_user_idfollowing_user_idusers_following
SELECT `up`.*
FROM `users_post` AS `up`
JOIN `users_following` AS `uf` ON `uf`.`following_user_id` = `up`.`by_user_id`
WHERE `uf`.`user_id` = 1
GROUP BY `up`.`id`
如果您還想包含users_post給定用戶的帖子,這就是您的查詢:
SELECT `up`.*
FROM `users_post` AS `up`
JOIN `users_following` AS `uf` ON `uf`.`following_user_id` = `up`.`by_user_id`
WHERE (`uf`.`user_id` = 1
OR `up`.`by_user_id` = 1)
GROUP BY `up`.`id`
如果這不是您想要的結(jié)果集,請?zhí)峁└嗾f明,我會(huì)盡力幫助您。
希望這可以幫助!
- 1 回答
- 0 關(guān)注
- 100 瀏覽
添加回答
舉報(bào)