Solved

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

Posted on 2007-11-27
4
167 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
  • 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 142

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now