Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:22:21+00:00 2026-06-10T10:22:21+00:00

I have 3 tables friends posts members friends ======== id, to, from (user_id’s), status

  • 0

I have 3 tables

friends
posts
members

friends
========
id, to, from (user_id's), status

there are 3 status's -1 = denied, 0 = no response/new, 1 = accepted



posts
=======
p_id, user_id (same as member_id), text


members
========
member_id, f_name, l_name

If like to select the text from the post in ‘posts’ combine it with the users name from ‘members’ and only display posts where the user_id is in the ‘friends’ table.

I would like to know if it can be done, I’ve tried an IN () statement in my query which worked, but it creates a new problem with generating the csv inside the IN (). I’d perfer to do this through mysql, but if it can’t be done I may use a global variable to store friend data (but then it will not be upto date or will have to be refreshed when a user gets a new friend).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:22:22+00:00Added an answer on June 10, 2026 at 10:22 am

    As I understand it, you want to find the name and posts of all your friends, not any friend that’s in the friend table at all…?

    Your own user id being in $myId, this should do it (newest posts first);

    EDIT: Added status check for friends

    SELECT m.f_name, m.l_name, p.`text`
    FROM members m
    JOIN posts p 
      ON m.member_id = p.user_id
    JOIN friends f 
      ON f.`to` = m.member_id OR f.`from` = m.member_id
    WHERE (f.`from` = $myId OR f.`to`= $myId)
      AND f.`status` = 1 AND m.member_id <> $myId
    ORDER BY p.p_id DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
I have two tables called 'posts' and 'friends'. I want to display the my
Hi, I have these two tables: users and friends (friend_status = 1 means the
Hi, I have these two tables: users and friends (friend_status = 1 means the
I have the following tables: team_members userid teamid users uid name_f name_l friends friend_id
I have a many-to-many relationship between two tables, let's say Friends and Foods. If
I have thee tables user_follow, images, users My user_id : 3 My Friend user_id
I have 3 tables - posts, friendships, and likes -- the important fields described
I have 3 tables: user_info , friend_match, posts user_info : account_id | username friend_match
I have 2 tables : users : contains id and name friends : contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.