diff options
Diffstat (limited to 'dbinit/functions.sql')
-rw-r--r-- | dbinit/functions.sql | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/dbinit/functions.sql b/dbinit/functions.sql index 4343210..34a64bc 100644 --- a/dbinit/functions.sql +++ b/dbinit/functions.sql @@ -1,3 +1,4 @@ +use `formula1`; drop function if exists udfTotalDistance; delimiter $$ @@ -6,10 +7,8 @@ returns int begin return ( select `circuit`.`length` * `circuit`.`laps` - from `circuit` - inner join `racedatecircuit` on `racedatecircuit`.`circuitID` = `circuit`.`ID` - inner join `racedate` on `racedate`.`ID` = `racedatecircuit`.`raceDateID` - inner join `race` on `race`.`raceDateID` = `racedate`.`ID` + from `race` + inner join `circuit` on `circuit`.`ID` = `race`.`circuitID` where `race`.`ID` = raceID); end$$ |