I'd like to select from multiple identically constructed tables returning values of three columns for each row where a value of one of the columns is found by another query. For example, an inefficient way to do this might be:
Select Film_Title, Main_Actor, Run_Time From Film_Table_1
Where Film_Title in
(Select Film_Title
From Awesome_Films_Table
Where Film_Year equals "1984")
UNION ALL
Select Film_Title, Main_Actor, Run_Time From Film_Table_2
Where Film_Title in
(Select Film_Title
From Awesome_Films_Table
Where Film_Year equals "1984")
Select Film_Title, Main_Actor, Run_Time From Film_Table_3
Where Film_Title in
(Select Film_Title
From Awesome_Films_Table
Where Film_Year equals "1984")
Select Film_Title, Main_Actor, Run_Time From Film_Table_4
Where Film_Title in
(Select Film_Title
From Awesome_Films_Table
Where Film_Year equals "1984");
In reality, I have many 'Film_Table_#' to select from. Can anyone advise how to achieve this more efficiently? I presume replacing:
Select Film_Title
From Awesome_Films_Table
Where Film_Year equals "1984"
That I currently have on each Where specifier with a single variable defined at the start might help, but I'm not sure how that might be achieved.