title: How to use foreign key when querying from two tables
body: <p>My question is quite basic. 
  It is about how can i build my query with using a foreign key to select certain information from two tables?</p>
  
  <pre><code>table vehicles
  +-------+----------+------------+
  | id_car| car_model| car_owner  |
  +-------+----------+------------+
  |  1    |       VW |         132|
  +-------+----------+------------+
  |  2    |       VW |         200|
  +-------+----------+------------+
  table users
  +-------+----------+------------+
  |user_id| user_name| user_phone |
  +-------+----------+------------+
  |  132  |     Peter|    555-555 |
  +-------+----------+------------+
  |  200  |      Jim |    555-333 |
  +-------+----------+------------+
  </code></pre>
  
  <p><code>car_owner</code> is foreign key in <code>vehicles</code> table which references to the primary key <code>user_id</code> of <code>users</code> table.</p>
  
  <p>So someone is searching for all VW cars and i want to have as populate the following information as html(yes, I know that this is not the correct way - i use this just to simplify the example and show which information from each table goes):</p>
  
  <pre><code>&gt;    echo "Car model:". `vehicles.car_model`
  &gt;    echo "Car owner:". `users.user_name`
  &gt;    echo "Contacts: ". `users.user_phone`
  </code></pre>
  
  <p>thanks in advance.</p>