|
Tutorial Five: |
Give a list of all the services which connect stops 115 and 191. ('Haymarket' and 'Portabello')
SELECT R1.num, R1.company FROM route R1, route R2
WHERE R1.stop = 115 AND R2.stop=191
AND R1.num=R2.num AND R1.company=R2.company;
Give a list of the services which connect the stops 'Craiglockhart' and 'Tollcross'
SELECT R1.num, R1.company FROM route R1, route R2, stops S1, stops S2
WHERE R1.stop = S1.id AND R2.stop=S2.id
AND R1.num=R2.num AND R1.company=R2.company
AND S1.name = 'Craiglockhart' AND S2.name = 'Tollcross';
Give a list of the stops which may be reached from 'Craiglockhart' by taking one bus. Include the details of the appropriate service.
SELECT R1.num, R1.company, S2.name FROM route R1, route R2, stops S1, stops S2
WHERE R1.stop = S1.id AND R2.stop = S2.id
AND R1.num=R2.num AND R1.company=R2.company
AND S1.name = 'Craiglockhart';
Show how it possible to get from Sighthill to Craiglockhart.
You might intersect all the places from Craiglockhart with all the places from Sighthill. This would at least be a start.
SELECT S2.name FROM route R1, route R2, stops S1, stops S2
WHERE R1.stop = S1.id AND R2.stop = S2.id
AND R1.num=R2.num AND R1.company=R2.company
AND S1.name = 'Craiglockhart'
INTERSECT
SELECT S2.name FROM route R1, route R2, stops S1, stops S2
WHERE R1.stop = S1.id AND R2.stop = S2.id
AND R1.num=R2.num AND R1.company=R2.company
AND S1.name = 'Sighthill';