I have two tables: stop_times and trips -- both tables share trip_id. I want to build a query so that I extract information from both tables using trip_id, but then "filter" that information based on something from the first table.
I came up with this to get my information without the "filtering":
SELECT stop_times.trip_id, stop_times.arrival_time, trips.route_id
FROM stop_times, trips
WHERE stop_times.trip_id = trips.trip_id;
This works fine, but then I try to "filter" using stop_id:
SELECT stop_times.trip_id, stop_times.arrival_time, trips.route_id
FROM stop_times, trips
WHERE stop_times.stop_id IN (SELECT stop_id
FROM stop_times
WHERE stop_id = '81');
but it merges information incorrectly.