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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:26:37+00:00 2026-05-30T16:26:37+00:00

I have been trying to understand joins for a while now, I’ve noticed quite

  • 0

I have been trying to understand joins for a while now, I’ve noticed quite a few examples showing how to retrieve a value based on a two-table query using a left / inner join. I will try to draw out my example for you all, hopefully it will aid in the explanation of my question.

Table 1:
project_id  |  project_name
    1          super-project

Table 2:
project_id  |  course_id       ---> project_id and course_id are foreign keys here.
    1              3

Table 3:
course_id  |  course_name      ---> course_id is a primary key here
    3      |  Writing 101

My Goal:

I would like to be able to return “Writing 101” by using the project_id. So, if I know the project_id is 1, I would query the db to find that the course_id associated with the current project is 3. I would then use the course_id of 3 to query table 3 and find that the related course_name is writing 101.

Is there a way to do this in a single query using join of some sort?

  • 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-30T16:26:38+00:00Added an answer on May 30, 2026 at 4:26 pm
    select course_name from Table3
    inner join Table2
    on Table2.course_id = Table3.course_id
    where Table2.project_id = 1
    

    Notice there is only 1 join needed!

    Also note that if the project_id = 1 is present in more than one course all of those courses will appear.

    Can you explain why only one join is needed as opposed to the answer below which requires two joins?

    The other answer does not require two joins. As the project_id is present in the “middle” table there is no need to look for it in Table1. Now, if you require the name of the project (which is not the case because you didn’t mention that in the question) then you would have to join the Table1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to understand OpenGL ES 2.0 on the iPhone for quite
I have been trying it for few days and I do not understand what
I have been trying to understand a bit more about the wider picture of
I have been trying to understand the way ActionScript's events are implemented, but I'm
I have been trying to work my way through Project Euler, and have noticed
I have been trying to get around this error for a day now and
I've been having quite a few problems trying to use Microsoft.SqlServer.Types.SqlGeography . I know
I have been trying to understand why it will not work for me. Im
For last 48 hours, I have been trying to understand Multithreading and Socket Programming
I have been trying to understand how they did those effects in http://artofflightmovie.com/ with

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.