0

I have some five tables which look like this

BugHistory             
--------------------   
BugHistoryID
BugId
EmployeeId                  

Bugs
--------------------
BugID
Description
ProjectID
PriorityID

Employee                    
-------------------      
EmployeeId
EmployeeName   

Projects                
-------------------     
ProjectID
ProjectName    

Priority
-------------------
PriorityID
PriorityName

I want to retrieve data from all of the tables, making BugHistory the main table.

I need [Description],[ProjectName],[PriorityName] from all the remaining four tables where EmployeeID is the key.

The data should be retrieved based on EmployeeID from BugHistory table; I will be getting the EmployeeID based on login. Can any one help me in writing this query?

1
  • 1
    What does your query look like? What have you tried? Commented Jul 23, 2012 at 13:58

1 Answer 1

4

This should get you what you need.

SELECT b.Description
    , pj.ProjectName
    , pr.PriorityName
FROM BugHistory bh
INNER JOIN Employee e
     ON bh.EmployeeId = e.EmployeeId
INNER JOIN Bugs b
     ON bh.BugId = b.BugId
INNER JOIN Project pj
    ON b.ProjectId = pj.ProjectId
INNER JOIN Priority pr
    ON b.PriorityId = pr.PriorityId
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.