I need some SQL help. I am a Java guy by trade and I really don't know even how to ask this question. I have 3 tables, Call them Person, Children, Friends. Person is an ID and a Name:
| id | name |
---------------------
| 1 | Joe |
Let say Children is the same but with a FK back to person
| id | personId | name |
-------------------------------------
| 1 | 1 | Frank |
| 2 | 1 | Dan |
and friends are the same thing
| id | personId | name |
-------------------------------------
| 1 | 1 | Will |
| 2 | 1 | Bob |
Obviously this is a simplified version of my real problem, but the structure is the same. I need to pull all of this data in one SQL pull such that I get this back
| personId | personName | childId | childName | friendId | friendName
------------------------------------------------------------------------------------------
| 1 | Joe | 1 | Frank | null | null
| 1 | Joe | 1 | Dan | null | null
| 1 | Joe | null | null | 1 | Will
| 1 | Joe | null | null | 2 | Bob
I have tried multiple join techniques, but can’t seem to crack it. SQL was never my best subject. Now I am parsing this into a Java object person with List<> of friends and children so obviously this will work too:
| personId | personName | childId | childName | friendId | friendName
------------------------------------------------------------------------------------------
| 1 | Joe | null | null | null | null
| null | null | 1 | Frank | null | null
| null | null | 1 | Dan | null | null
| null | null | null | null | 1 | Will
| null | null | null | null | 2 | Bob
Anything that will allow a clean for loop in my code to build this.
Thanks!