这个SQL语句显示了我关注的每个人的帖子。
我该如何编辑它,以便它也显示我的帖子和我关注的人?

$query_posts = "
SELECT
    post.sqlid,
    post.status,
    post.username_posting,
    post.date_time,
    post.status_id,
FROM posts
INNER JOIN followers
    ON post.username_posting = followers.following
WHERE followers.follower = '$login_user'";

最佳答案

尝试使用OR在查询中添加post.username_posting条件

$query_posts = "SELECT
   post.sqlid,
   post.status,
   post.username_posting,
   post.date_time,
   post.status_id
FROM posts
INNER JOIN followers ON post.username_posting = followers.following
WHERE
followers.follower = '$login_user' OR post.username_posting = '$login_user'";

关于php - 添加条件以将我的帖子显示给现有查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46871094/

10-13 02:55