Got 3 Tables: pers, skills, articles (persons have n skills and wrote n articles)
(T1) pers
1 John
2 Joe
(T2) skills
1 John_sings
1 John_laughs
2 Joe_runs
(T3) article
1 John_article_1
2 Joe_article_1
3 Joe_article_2
I expect:
John - John_laughs - John_article_1
John - John_sings - [NULL]
Joe - Joe_runs - Joe_article_1
Joe - [NULL] - Joe_article_2
For we have 2 separate 1:n relations a consecutive join won't do it -> not T1 x T2 x T3, rather (T1 x T2) x (T1 x T3) according to this question.
I've tried:
SELECT child1.id,
child1.name,
child1.skill,
child2.title
FROM
(SELECT pers.id,
pers.name,
skills.skill
FROM pers
LEFT JOIN skills ON pers.id = skills.pers_id) child1
INNER JOIN
(SELECT pers.id,
article.title
FROM pers
LEFT JOIN article ON pers.id = article.pers_id) child2 ON child1.id = child2.id
but this shows
John - John_laughs - John_article_1
John - John_sings - John_article_1
Joe - Joe_runs - Joe_article_1
Joe - Joe_runs - Joe_article_2
Obviously, I don't want "Joe_runs" two times, neither "John_article_1" two times.
Appreciate any suggestion!