Solved

How do I select data that is in Two different table...

Posted on 2007-11-27
4
213 Views
Last Modified: 2010-04-21
I need a help on SQL query in MS SQL 2005

I have two tables with this column below:
Member(Table): MemberID, LastName, FirstName
Board(Table): BoardID, CreatorMemberID, EscalatedMemberID, CompletedMemberID

CreatorMemberID, EscalatedMemberID, CompletedMemberID has MemberID value that is Constraint Foriegn Key with Member Table's MemberID.

Here is my question.
How do I make query that will select CreatorMember's First & Last Name, EscalatedMember's First & Name , and CompletedMember's First & Last Name?

If I need to select  CreatorMember's First & LastName, I know how to do it by using JOIN, but how do I use JOIN to bring all of their firstname, and lastname.

Thank you.
0
Comment
Question by:erin027
[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
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20363400
like the select statement which you use to CreatorMember in the same way create for others too and have UNION between all three select statements
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 20363407
or 3 joins:


I have two tables with this column below:
Member(Table): MemberID, LastName, FirstName 
 select b.boardid, cr.lastname Creator_lastname, em.lastname as Escalated_lastname, cm.lastname as Completed_lastname
 FROM Board b
 left join Member cr
   on cr.memberid = b.CreatorMemberID
 left join Member em
   on em.memberid = b.EscalatedMemberID
 left join Member cm
   on cm.memberid = b.CompletedMemberID

Open in new window

0
 

Author Comment

by:erin027
ID: 20363408
Thank you asvforce.
But can you give me an example query. I am beginner... Sorry.
0
 

Author Closing Comment

by:erin027
ID: 31411358
Always, Thank you angellll
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 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