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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:47:44+00:00 2026-06-17T23:47:44+00:00

i have a table setup as the folowing I am trying to write one

  • 0

i have a table setup as the folowing

enter image description here

I am trying to write one query to return the result where status=1 confirmed =1 and user ID=specified. I want the result to dispay the user id , the name associated to that user id, the freind id and the name associated to that freind id. So far following tutorials on the web i have come up with the following query

SELECT `freinds.User ID`, `freinds.Freind ID`, `users.User`, `users.User` FROM `freinds` WHERE `User ID`= 6 INNER JOIN `users` on `users.ID`=6 AND `users.ID`=`freinds.Freind ID`

However i am getting an sql error with this query. I think what i am supposed to do is Inner join the user table twice but i am not exactly sure as to how to do it

  • 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-17T23:47:46+00:00Added an answer on June 17, 2026 at 11:47 pm

    the problem is you have wrap the tablename and columnname with backtick as a whole. you need to separate it, or if the name is not on `MySQL Reserved Keywords, remove the backticks.

    You also need to join the table User twice so you can get the names for each ID on table Freinds.

    SELECT  a.`User ID`, 
            a.`Freind ID`, 
            b.User FriendName,
            c.User UserName
    FROM    `freinds` a
            INNER JOIN `users` b 
                ON b.ID = a.`Freind ID`
            INNER JOIN users c
                ON c.id = a.`user ID`
    WHERE   `User ID`= 6 
    

    As a sidenote, if one of the ID is nullable, LEFT JOIN is preferred than INNER JOIN.

    To fully gain knowledge about joins, kindly visit the link below:

    • Visual Representation of SQL Joins
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with itemid|fieldid|value and i'm trying to setup a query that
I have table with Names such as JS Engineering Services$Web User Setup Header and
Here's my toy setup. I have 3 tables. One table is a guest list
I have a common User / Role setup, with a user_role join table. I'm
I have the following setup: Table: Question QuestionId Table: QuestionTag QuestionId TagId Table: Tag
I have the following setup in MS IE8: <table class=my-info> <tbody> <tr> <td class=info-left>First
I have created a GUI that will setup the pivot table. For example, I
I have a MySQL table setup as follows: +---------------+-------------+------+-----+---------+----------------+ | Field | Type |
I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`
I have the following setup: A sortable list where one of the <li> has

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.