Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to "ASSIGN" a RecordID based on 1st character of a Field? 8 36
MS SQL page split per second is high 19 95
Caste datetime 2 57
kill process lock Sql server 9 50
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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