I\'m working with some GTFS data and would like to be able to create a list of all stops associated served by a route. I don\'t really understand how to do with with GTFS da
If the direction of the stop is needed, a change in Lukmaan's answer should be done:
SELECT unique_stops.route_id, unique_stops.stop_id, stop_name, stop_desc, stop_lat, stop_lon, unique_stops.direction_id
FROM
stops,
(SELECT stop_id, route_id, direction_id
FROM
stop_times,
(SELECT trip_id, route_id, direction_id
FROM trips
WHERE route_id IN (801, 803)
GROUP BY direction_id
) AS unique_trips
WHERE stop_times.trip_id = unique_trips.id
GROUP BY stop_id, direction_id) AS unique_stops
WHERE stops.stop_id = unique_stops.stop_id
If you add also stop_times.stop_sequence
the same way, and order by direction and stop_sequence, the stops will be sorted as they are in the trip.