From 9a6b346598d19e13a4bf0d3af6a34573253e16b7 Mon Sep 17 00:00:00 2001
From: lonkaars <loek@pipeframe.xyz>
Date: Sun, 9 Apr 2023 14:14:15 +0200
Subject: fix views and functions

---
 dbinit/functions.sql | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

(limited to 'dbinit/functions.sql')

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$$
 
-- 
cgit v1.2.3

