Let’s say I have the following tables
Collection DirectorId StudioId
1 NULL 1
2 2 NULL
3 NULL 2
Director MovieId
1 1
2 4
Studio MovieId
1 1
2 3
2 4
1 2
The collection table will always have either director or studio id but never both.
How could I write a query to get all the movies in one a collection so that I end up with
CollectionID MovieID
1 1
1 2
2 4
3 3
3 4
I hope this makes sense
This should work (not sure about your column names, but you get the idea):