Skip to content
Advertisement

SQL Query from getting SubChild to Child to Parent Tables

Good day,

I’m trying to create a custom query for my scenario. Here’s the DEMO I created.

Suppose I have 2 or more parent tables and this table will be consume by a child table.

tblParent1

tblParent2

tblParent3

Then there’s a child table where it consumes these 3 parent tables.

tblChild

And the child of child table

tblChildOfChild

What I tried so far is using the left join between tblChildOfChild and tblChild but I don’t have an idea how can I access the 3 parents of the tblChild. What I need is create a query that has condition in tblChildOfChild. What I’ve done so far is shown below.

But I’m getting a different result from what I expected.

The expected result should be:

I’m stuck with this for hours. I hope somebody can help me or give some new knowledge.

Advertisement

Answer

I think the only thing OP do wrong is join the wrong key.

anyway try this first.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement