John Woo
John Woo

Reputation: 263683

SQL Server Query problem

I wanted so much help from you guys :( ok, my problem is how to create a query that satifies my needs.. I have 3 Tables namely TableA(ColID, ColName, ColRec), TableB (ColRec, bID), and TableC(bID, xGrade, xTake, ColID).

Sample Record

enter image description here

When I search for the ColID from TableA I want to display all xGrade from TableC like this below:

enter image description here

but instead of above result I get this:

enter image description here

It also displays all records that matches bID from TableB and bID from TableC.

I can't finish my project without this query :( please help me guys..

Thanks in advance!

Upvotes: 0

Views: 90

Answers (1)

Wegged
Wegged

Reputation: 2413

SELECT 
    A.ColID, B.bID, C.xGrade 
FROM 
    TableA A 
INNER JOIN 
    TableB B ON A.ColRec =  B.ColRec 
LEFT JOIN 
    TableC C on B.bID = C.bID AND A.ColID = C.ColID 
WHERE 
    A.ColID  = 1

will that work?

Upvotes: 3

Related Questions