title: MySQL Select By Newest Timestamp
body: <p>I've seen some similar types of questions on SO, however, I have not been able to find a solution to my specific issue.  (FYI, these are not my real columns, just a shortened example).</p>
  <p>I have a basic table   <code>my_table</code>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>user_1</th>
  <th>user_2</th>
  <th>timestamp</th>
  <th>note(not part of table)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>23</td>
  <td>25</td>
  <td>2012-08-10 22:00:00</td>
  <td></td>
  </tr>
  <tr>
  <td>24</td>
  <td>22</td>
  <td>2012-08-10 19:00:00</td>
  <td>&lt;=== I would like to return this row</td>
  </tr>
  <tr>
  <td>24</td>
  <td>22</td>
  <td>2012-08-10 17:00:00</td>
  <td></td>
  </tr>
  <tr>
  <td>21</td>
  <td>17</td>
  <td>2012-08-10 15:00:00</td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>So, what I want to do is be able to:</p>
  <pre><code> 1) Select the &quot;newest&quot; row, based on timestamp AND 
   2) Select the 'user_2' column when given a value.  
  </code></pre>
  <p>I have tried something like:</p>
  <pre><code> SELECT *
   FROM my_table
   WHERE user_2 = 22
   AND timestamp = (
   SELECT MAX( timestamp )
   FROM my_table )
   LIMIT 1 
  </code></pre>
  <p>But this does not return the row I am looking for. Any help on fixing this query would be great.</p>
  <p>Thanks very much.</p>