C
C
Coder3212019-12-05 14:37:59
PostgreSQL
Coder321, 2019-12-05 14:37:59

How to organize a query with multiple joins through spanning tables?

5de8ebaae6218802529803.png
There is such a scheme. How to get a user with all third children first, second,?
You need the most productive option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
QSandrew, 2019-12-05
@QSandrew

in T-Sql. If data in other tables is optional, then Left, else INNER
SELECT *
FROM users as u
LEFT JOIN first as f ON f.users_id=u.id
LEFT JOIN first_second as fs ON f.id=fs.first_Id
LEFT JOIN second as s ON s.id=fs.second_Id
LEFT JOIN second_third as st ON st.second_Id=s.id
LEFT JOIN third as t ON st.third_Id=t.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question