Hallo iedereen,
Kan iemand mij wat meer uitleg geven over de structuur en opbouw van de onderstaande querries? en hoe ik dit moet lezen? Ik ken al sommige functies van sql maar onderstaand querries vind ik verwarrend.
[size=2][font=arial, sans-serif]drop procedure DagEnUurVolgendeVluchtPerLuchthaven ; [/font][/size]
[size=2][font=arial, sans-serif]delimiter //[/font][/size]
[size=2][font=arial, sans-serif]create procedure DagEnUurVolgendeVluchtPerLuchthaven()[/font][/size]
[size=2][font=arial, sans-serif] begin [/font][/size]
[size=2][font=arial, sans-serif] select a.AirportName Luchthaven, min(fd.depday) Dag, min(fd.deptime) Uur[/font][/size]
[size=2][font=arial, sans-serif] from airport a[/font][/size]
[size=2][font=arial, sans-serif] join route r on r.`from`= a.AirportID[/font][/size]
[size=2][font=arial, sans-serif] join flight f on f.routeid = r.routeID[/font][/size]
[size=2][font=arial, sans-serif] join flightdep fd on fd.flightid = f.FlightID[/font][/size]
[size=2][font=arial, sans-serif] where fd.DepDay >= DayOfWeek(now())[/font][/size]
[size=2][font=arial, sans-serif] and fd.DepTime > Time(now())[/font][/size]
[size=2][font=arial, sans-serif] group by a.AirportName ;[/font][/size]
[size=2][font=arial, sans-serif] end //[/font][/size]
[size=2][font=arial, sans-serif]delimiter ;[/font][/size]
[size=2][font=arial, sans-serif]CREATE PROCEDURE RoutesNaarAirport(in MyAirportode char(3))
begin
drop table if exists AfstandsCategorieen;
create temporary table AfstandsCategorieen(CategorieNaam char(21), van int, tot int);
insert into AfstandsCategorieen values ('short distance',0, 999);
insert into AfstandsCategorieen values ('intermediate distance',1000, 3000);
insert into AfstandsCategorieen values ('long distance',3001, 999999);
select a_from.Airportname as van, a_to.AirportName as naar, r.distance as afstand, ac.CategorieNaam as afstandscategorie
from airport as a_from, airport as a_to, route as r, AfstandsCategorieen as ac
where (r.`from` = a_from.AirportID )
and (r.`to` = a_to.AirportID )
and (r.Distance between ac.van and ac.tot)
and (a_to.AirportCode = MyAirportode);
-- drop table if exists AfstandsCategorieen;
end//
delimiter ;[/font][/size]
Hopelijk kan er iemand mij verder helpen hiermee?
Groeten
Tom