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 603741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:57:50+00:00 2026-05-13T16:57:50+00:00

I have 2 tables : users : contains id and name friends : contains

  • 0

I have 2 tables :

users : contains id and name
friends : contains id1 and id2

Let’s suppose I have this data in the users table :

id : 1 , name : FinalDestiny
id : 2 , name : George

And this data in the friends table:

id1: 1 , id2: 2

So this means that 1 is friend with 2.

I need with one single query to say that id1 is friend with id2( but I need the names) Like: FinalDestiny is friend with George. I have to make one mysql inner or left join but I don’t know how

  • 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-05-13T16:57:51+00:00Added an answer on May 13, 2026 at 4:57 pm

    use aliases and double-join the user table with the friends table:

        SELECT `u1`.`name` `name1`, `u2`.`name` `name2`
          FROM `friends` `f`
    INNER JOIN `users` `u1`
            ON `f`.`id1` = `u1`.`id`
    INNER JOIN `users` `u2`
            ON `f`.`id2` = `u2`.`id`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a table called Users, which contains your typical information: Id, Name,
i have USERS TABLE that contains the following fields _id name number_of_posts and i
I have two data tables. One contains all of users identifiable informaiton (username, id,
I have a table that contains articles posted by users. The structure of the
I have the following tables in MySQL: users profile rates In the users table,
I have three tables. Let's call them a, b, and a_to_b. a_to_b contains (among
Basically, I have a table which contains a few properties for a company. This
I have three tables say 'user', 'user_resources' and 'desktop_resources'. 'user' contains - emp_id,name and
I have this problem. Given a users table that consists of users' username in
I have two tables in my MySQL database, users and tweets, as follows: TABLE

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.