Part 9:Self join
stops |
---|
id |
name |
route |
---|
num |
company |
pos |
stop |
1. How many stops are in the database.
SELECT COUNT(DISTINCT(id))
FROM stops
2. Find the id value for the stop 'Craiglockhart'.
SELECT id
FROM stops
WHERE name='Craiglockhart'
3. Give the id and the name for the stops on the '4' 'LRT' service.
SELECT id,name
FROM route JOIN stops ON (stop=id)
WHERE num='4' AND company='LRT'
4. The query