Warning: this query requires user input. Therefore, the printout below may not display correctly.
SELECT t1.`National Park`,t1.`Trail Name` as 'Trail 1',t2.`Trail Name` as 'Trail 2',t1.`Trail Difficulty`,Temperature.Temp as 'Temperature'
FROM (
SELECT pname
,plat
,wslat
,plong
,wslong
,wsid
,distance
FROM (
SELECT
p.Name as pname
,p.Latitude as plat
,ws.Latitude as wslat
,p.Longitude as plong
,ws.Longitude as wslong
,ws.ID as wsid
,3956 * 2 * ASIN(SQRT(POWER(SIN((p.Latitude-ws.Latitude) * pi()/180 / 2), 2) +COS(p.Latitude * pi()/180) *COS(ws.Latitude * pi()/180) *POWER(SIN((p.Longitude - ws.Longitude) * pi()/180 / 2), 2) )) as distance
FROM `WeatherStation` ws,`Parks` p
ORDER BY Distance
) as park
GROUP BY pname
) AS WS_park_key
INNER JOIN Temperature
ON WS_park_key.wsid=Temperature.ID
INNER JOIN Parks
ON WS_park_key.pname=Parks.Name
INNER JOIN Trails t1
ON Parks.Name=t1.`National Park`
INNER JOIN Trails t2
ON t1.`Trail Difficulty`=t2.`Trail Difficulty`
WHERE t1.`Trail Name`