I need to find the users who have either
- a shared video credit;
- a shared production credit; or
- a shared group.
This is currently the query I came up with:
SELECT profile_id FROM productions_productionmember WHERE production_id in
(SELECT production_id FROM productions_productionmember WHERE profile_id=?)
UNION
SELECT profile_id FROM groups_groupmember WHERE group_id in
(SELECT group_id FROM groups_groupmember WHERE profile_id=?)
UNION
SELECT profile_id FROM videos_videocredit WHERE video_id in
(SELECT video_id FROM videos_videocredit WHERE profile_id=?)
Relevant tables:
groups_groupmember
- profile_id
- group_id
videos_videocredit
- profile_id
- video_id
productions_productionmember
- profile_id
- production_id
How can improve on this query?
1 Answer