[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

selecting from three or more relational tables

Posted on 2013-12-27
1
Medium Priority
?
190 Views
Last Modified: 2013-12-28
I have Three tables in SQL 2012.  They are related in the following scheme below.

tblGoals
GoalID - Primary Key

tblObjectives
GoalID- Foreign Key
ObjectiveID- Primary Key

tblPI
ObjectiveID- Foreign Key
PIID-Primary Key

 If I would like to call all the records between all the tables (ie, Goals, related Objectives, related PI, how would I select them all?

Would it look like this?


Select *
From tblGoals G
Inner Join tblObjective O on G.GoalID = O.GoalID Inner Join ????

You see where I am struggling....
0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
Steve Wales earned 2000 total points
ID: 39743100
You just about had it.

Select *
From tblGoals G
Inner Join tblObjective O on G.GoalID = O.GoalID
Inner Join tblPI P on O.ObjectiveID = P.ObjectiveID

That should cover it, I believe.

If you want to get more selective you can list the various columns:

select g.GoalID, O.ObjectiveID, P.PIID, etc etc etc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question