Solved

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

Posted on 2007-11-27
4
181 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Encryption question 2 50
MS SQL order by with "over" statement and row_number() 11 39
Query 14 54
Urgent help needed! Unable to to paste in query designer 29 35
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…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

24 Experts available now in Live!

Get 1:1 Help Now