0

Hello
I have two tables a Master and Child. I want to return a recordset that has all of the Master records and any related child values.
Sample Data:
Master Table
'id' 'field1'
1 Test1
2 Test2
3 Test3
Child Table
'id' 'masterID' 'field1'
1 2 Child1The following code will only return one record:

SELECT master.id, master.field1, child.field1
FROM master INNER JOIN child on master.id = child.masterID
WHERE child.id = 1

Resulting recordset:
2,Test2, Child1
What I need to achieve is:
Resulting recordset:
1,Test1,NULL
2,Test2,Child1
3,Test3,NULL
I hope that makes sense. I am not even sure if it is possible.

I have tried using various OUTER JOIN combinations but the result is the same.

Regards
James

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

You just didn't try right outer join

SELECT     master.id AS [Master ID], master.field1 AS [Master field], child.field1 AS [Child Field]
FROM         child RIGHT OUTER JOIN
                      master ON child.masterid = master.id
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.