Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 join these tables

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-10-20 : 06:53:07
Hi,
I have 3 tables:
Employee, Team, Connection

Employee
EID EName Rank
1 A 1
2 B 2
3 C 3


Team
TID TName Day
11 AA M
12 BB T
13 CC W


Connection
EmpID TeamID
1 11
2 12
3 13


I want the result to be like this:

TID TName Day EID EName Rank
11 AA M 1 A 1
12 BB T 2 B 2
13 CC W 3 C 3


Is it possible to get this result?
Thanks,
Mavericky

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-10-20 : 07:14:26
Yes. It looks like it should be really simple. When is the assignment due?

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Grifter
Constraint Violating Yak Guru

274 Posts

Posted - 2011-10-20 : 07:38:54
[code]SELECT t.TID AS [Team ID], t.TName AS [Team Name], t.Day AS [Team Day], e.EID AS [Employee ID], e.EName AS [Employee Name], e.Rank AS [Employee Rank]
FROM connection c
INNER JOIN team t ON c.TeamID = t.TID
INNER JOIN employee e ON c.EmpID = e.EID[/code]

G
Go to Top of Page

jassi.singh
Posting Yak Master

122 Posts

Posted - 2011-10-20 : 08:12:23
Try this

SELECT
team.TID,team.TName,team.Day,Employee.EID,Employee.EName,Employee.Rank
FROM connection
INNER JOIN employee ON connection.EmpID = employee.EID
INNER JOIN team ON connection.TeamID = team.TID

Please mark answer as accepted if it helped you.

Thanks,
Jassi Singh
Go to Top of Page
   

- Advertisement -