Joining tables in WorkBench

0 votes
This Workbench query gives me the number of 3 year old winners where Acclamation is the sire:

SELECT * from historic_runners WHERE sire_name = "Acclamation" and age = 3 and finish_position = 1

(1) Is there a better way to carry out this query? (2) What would be the Workbench script for all winners at say the Curragh where Acclamation is the sire?
asked Sep 12, 2022 by jnestor3 Novice (260 points)
edited Sep 12, 2022 by jnestor3

1 Answer

0 votes

Hi - 

1.  There is nothing wrong"with the query although you might want to make the query more focused by selecting specific variables as opposed to all (*) variables

2.  To introduce variables (such as course) from the historic_races table, join both tables together and include the criteria required in the where statement, eg.

SELECT * from historic_runners join historic_races using (race_id) WHERE sire_name = "Acclamation" and age = 3 and finish_position = 1 and course = "Curragh"

Last but not least, you can also use the variables in historic_runners_insights instead of hiistoric_runners for extra information.

answered Sep 14, 2022 by colin Frankel (18,270 points)
...