Mysql
 sql >> Datenbank >  >> RDS >> Mysql

SQL-Abfrage vom Erhalten von SubChild zu Child zu Parent-Tabellen

Ich denke, das einzige, was OP falsch macht, ist join der falsche Schlüssel.

versuchen Sie es trotzdem zuerst.

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