title: Displaying data from an external relationship in PostgreSQL
body: <p>I have a database that I'm having trouble filtering using values from a table that does not have a direct relationship with my main table.</p>
  <p>My database is roughly as follows</p>
  <p><strong>table_main</strong></p>
  <pre><code>+----+------------+--------+-------+-------+
  | id | date       | veh_id | dep   | arr   |
  +----+------------+--------+-------+-------+
  | 1  | 2020-01-01 | 1      | 00:00 | 10:00 |
  +----+------------+--------+-------+-------+
  </code></pre>
  <p><strong>table_vehicles</strong></p>
  <pre><code>+----+------------+-----------------+
  | id | reg_number | vehicle_type_id |
  +----+------------+-----------------+
  | 1  | 10         | 1               |
  +----+------------+-----------------+
  | 2  | 11         | 1               |
  +----+------------+-----------------+
  | 3  | 12         | 1               |
  +----+------------+-----------------+
  | 4  | 13         | 2               |
  +----+------------+-----------------+
  </code></pre>
  <p><strong>table_vehicle_types</strong></p>
  <pre><code>+----+-------+--------+
  | id | make  | model  |
  +----+-------+--------+
  | 1  | Chevy | Impala |
  +----+-------+--------+
  | 2  | Ford  | Fusion |
  +----+-------+------- +
  </code></pre>
  <p>table_vehicle_types is linked to table_vehicles, and table_vehicles is linked to table_main</p>
  <p>What I want to be able to do is display my table_main in a select query and filter it to show a specific vehicle type, for example I want to see all trips made by Impalas when I query table_main, however I do not know how to go about that.</p>
  <p>Any help with this would be greatly appreciated, thank you</p>