I have one parent with many children and I would like from the parent Id selecting value from 3 children, if it’s possible.
I tried this
SELECT children1.value1, children2.value2, children3.value3 FROM children1, children2, children3 JOIN ... Some code ... WHERE parent.id = 1;
I’ve tried to write the JOIN with no success …
Advertisement
Answer
SELECT c1.value1, c2.value1, c3.value1 FROM parent p LEFT JOIN children1 c1 ON c1.idParent = p.id LEFT JOIN children2 c2 ON c2.idParent = p.id LEFT JOIN children3 c3 ON c3.idParent = p.id WHERE p.id = 1
LEFT JOIN
is an assumption though.