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

  • SEARCH
  • Home
  • 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 8342185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:41:48+00:00 2026-06-09T05:41:48+00:00

Im making a friends list which JOINs 2 tables, the FRIENDS table, and the

  • 0

Im making a friends list which JOINs 2 tables, the FRIENDS table, and the PLAYERS table.

friends table

 player   target     status
 -----------------------------
 john     eric       invited
 roger    moore      friends
 stan     winston    friends

players table

 name      pic     
 -------------------
 john     lol.jpg
 stan     skinhead.gif

Now when on a players page, I need to loop through the friends table and find out how many friends they have. So for this i’d have to check BOTH the player field, and the target field that = $name

Then to get the pic id have to JOIN that with the players table.

This is my query so far, which doesnt work obviously (bit of psuedo):

SELECT p.pic, p.name FROM friends f INNER JOIN players p ON (player OR target)=p.name WHERE (f.player='" .$name. "' OR f.target='" .$name. "') AND status='friends'

$name is the name of the players profile you are on.

Can anyone tell me how to tweak this to make it work?

  • 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-09T05:41:49+00:00Added an answer on June 9, 2026 at 5:41 am

    You’ll need to use a union to get it all in one query.

    SELECT * FROM friends JOIN players ON (target = name AND status = friends)
    WHERE player = ?
    UNION ALL
    SELECT * FROM friends JOIN players ON (player = name AND status = friends)
    WHERE target = ?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Friends i am making an application in which i am using Map Activity. Now
Hi im making a small site to help me and friends learn languages. Typical
Making an adobe flex ui in which data that is calculated must use proprietary
Hello friends I am getting the following error while making the foreign key 'tbl_course'
Dear friends, i'm concerned if i'm making a bad use of references in C++
I'm making a simple chat program for me and my friends as a tech
Why should overloading of stream operators(<<,>>) be kept as friends rather than making them
I am making an App in which i have a view where i am
I'm stuck at a point in making mutual friends code for my website. I
Im making a simple app for some friends to use on there android phone

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.