diff options
Diffstat (limited to 'dbinit/functions.sql')
-rw-r--r-- | dbinit/functions.sql | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dbinit/functions.sql b/dbinit/functions.sql new file mode 100644 index 0000000..4343210 --- /dev/null +++ b/dbinit/functions.sql @@ -0,0 +1,16 @@ +drop function if exists udfTotalDistance; + +delimiter $$ +create function udfTotalDistance(raceID int) +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` + where `race`.`ID` = raceID); +end$$ + +delimiter ; |