Skip to content
Advertisement

SELECT requiring multiple joins with one to many tables in PostgreSQL [closed]

Toy example: I have a database schema shown in this EDR diagram:

EDR diagram

  • Student one-to-many with StudyGroup
  • StudyGroup one-to-many with Borrowed
  • Borrowed one-to-many with Books.

I want to get all books that have been borrowed by all study groups of a single Student.

I’m unsure how to construct the multiple joins in this case,

Advertisement

Answer

I recommend you to read SQL JOIN and different types of JOINs

If you want your table as shown:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement