title: Min and Max values from one table and another value from another table
body: <p>I have few tables with some data in them.
  And my task is to find highest and lowest observed temperature and where they were measured (With one query).</p>
  <p>My tables :</p>
  <p>location</p>
  <pre><code>| location_id | location_name |
  | --------    | --------------|
  | 1           | New York      |
  | 2           | Chicago       |
  | 3           | Los Angeles   |
  | 4           | San Francisco |
  </code></pre>
  <p>observation</p>
  <pre><code>| observation_id | ref_location |temperature|
  | --------       | ------------ | -----     |
  | 1              | 1            |20.0       |
  | 2              | 2            |18.0       |
  | 3              | 3            |3.0        |
  </code></pre>
  <p>As you can see location_id and ref_location has to be linked between eachother</p>
  <p>This is how my answer should look like.</p>
  <pre><code>if(!empty($result))
  {
      echo &quot;&lt;table&gt;&quot;;
      while($row = mysqli_fetch_array($result))
      {
          echo &quot;&lt;tr&gt;
                  &lt;td&gt;&quot;.$row['location_name'].&quot;&lt;/td&gt;
                  &lt;td&gt;&quot;.$row['temperature'].&quot;&lt;/td&gt;
              &lt;/tr&gt;&quot;;
      }
      echo &quot;&lt;/table&gt;&quot;;
  }
  </code></pre>
  <p>At the moment my query looks like this:</p>
  <pre><code>SELECT MIN(observation.temperature) AS temperature,
          MAX(observation.temperature) AS temperature, 
          location_name AS location_name 
  FROM observation 
      INNER JOIN location ON observation.ref_location=location.location_id;
  </code></pre>