SQL Query from getting SubChild to Child to Parent Tables

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

anyway try this first.

SELECT t.id, t.feedback, t1.note as note, p1.name as parent1, p2.name as parent2, 
p3.name as parent3
FROM tblChildOfChild t 
LEFT JOIN tblChild t1 ON t.tblChild_key = t1.id
LEFT JOIN tblParent1 p1 ON t1.tblParent1_key = p1.id
LEFT JOIN tblParent2 p2 ON t1.tblParent2_key = p2.id
LEFT JOIN tblParent3 p3 ON t1.tblParent3_key = p3.id
WHERE t.id = 1

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top