Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Created May 6, 2013 13:02
Show Gist options
  • Save elmariachi111/5524959 to your computer and use it in GitHub Desktop.
Save elmariachi111/5524959 to your computer and use it in GitHub Desktop.
An SQL query that JOINs GTFS relational data into something more friendly for JSON transformation
USE hack_test;
SELECT DISTINCT
s.stop_id, s.stop_sequence, s.pickup_type, s.drop_off_type, t.route_id,
t.trip_headsign, r.route_short_name,r.agency_id, st.stop_name,
st.stop_lat, st.stop_lon
FROM stop_times s LEFT JOIN trips t ON s.trip_id = t.trip_id
LEFT JOIN routes r ON t.route_id = r.route_id
LEFT JOIN stops st ON s.stop_id = st.stop_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment