Skip to content
Advertisement

How to join one column multiple times to many columns? – SQL

I have two tables like:

I want an output like:

I think this will require JOIN and UNION ALL, but I can’t figure out how exactly to put everything together. I’m confused because we’ll need to join multiple times per row.

Would appreciate any help, thanks

Advertisement

Answer

You can do:

However, I would say the cardinalities of those relationships look sketchy. I would revise the database model design.

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