title: JOIN with MAX in WHERE
body: <p>There are 2 tables:</p>
  
  <p>Table <strong>temperature_now</strong>:</p>
  
  <pre><code>machine_id | temperature
  ------------------------
      1      |     15
      2      |     20
      3      |     13
  </code></pre>
  
  <p>Table <strong>temperature_history</strong>:</p>
  
  <pre><code>change_id | machine_id | temperature | controller
  -------------------------------------------------
      1           1            6           Carl
      2           2            9           Steve
      3           1            7           John
      4           1            15          Peter
      5           2            20          Peter
      6           3            13          Martin
  </code></pre>
  
  <p>temperature_now.machine_id = temperature_history.machine_id</p>
  
  <p>change_id is auto_increment</p>
  
  <p><strong>I need to get the last change of temperature at each machine</strong>:</p>
  
  <pre><code>machine_id | temperature_now | temperature_before | controller
  --------------------------------------------------------------
      1              15                   7              John
      2              20                   9              Steve
  </code></pre>
  
  <p>Thanks for your help.</p>