문제 5. Execute the self join shown and observe that b.stop gives all the places you can get to from Craiglockhart, without changing routes. Change the query so that it shows the services from Craiglockhart to London Road.
표시된 자체 결합을 실행하고 경로를 변경하지 않고 b.stop이 크레이그록하트에서 갈 수 있는 모든 위치를 제공하는지 관찰합니다. Craiglockhart에서 London Road까지의 서비스를 표시하도록 쿼리를 변경합니다.
문제 6. 표시된 쿼리는 이전 쿼리와 유사하지만 두 개의 정지 테이블 사본을 결합하면 번호가 아닌 이름으로 정지를 참조할 수 있습니다. 'Craiglockhart'와 'London Road' 사이의 서비스가 표시되도록 쿼리를 변경합니다. 만약 당신이 이러한 장소에 지쳤다면, '톨크로스'에 대항하여 '페어마일헤드'를 시도해 보세요.
정답
1
2
3
4
5
6
7
8
9
10
11
SELECT a.company, a.num, stopa.name, stopb.name
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name ='Craiglockhart' and stopb.name ='London Road';
문제 9. LRT 회사가 제공하는 'Craiglockhart' 자체 버스를 포함하여 'Craiglockhart'에서 한 번에 도착할 수 있는 정류장의 명확한 목록을 제공하십시오. 관련 서비스의 회사 및 버스 번호를 포함하세요.
Give a distinct list of the stops which may be reached from 'Craiglockhart' by taking one bus, including 'Craiglockhart' itself, offered by the LRT company. Include the company and bus no. of the relevant services.