title: Using max value as a filter
body: <p>I'm having issues writing a MySQL query. It's actually a pretty large one, and the part I'm having issues with is about this <em>User_City</em> table :</p>
  
  <pre><code>| user_id | int(11)
  | city_id | int(11)
  | from    | date
  | to      | date
  </code></pre>
  
  <p>I would like to compare the ID of the city in which the user we're looking for currently lives, with the ID provided by the user performing the research. I have something like this :</p>
  
  <pre><code>User_City.user_id=User.id and User_City.city_id='.$city_id.' and...
  </code></pre>
  
  <p>Now the problem is writing the last part where I specify that I want to compare the ID of the most recent entry, meaning the line in which the <em>from</em> field has the highest value but the <em>user_id</em> is still the same.</p>