title: Most efficient way to find the closest integer in MySQL?
body: <p>I have a table in a MySQL database from which I want to select the row with the closest timestamp to another given timestamp.</p>
  
  <p><code>time</code> is the timestamp column (an integer UNIX timestamp). I chose <code>1250710000</code> arbitrarily.</p>
  
  <p>This is the query that I've come up with, and I'm wondering if there's a more efficient way to do it:</p>
  
  <pre><code>SELECT *, ABS(time - 1250710000) AS time_dist FROM table
   ORDER BY time_dist ASC LIMIT 1
  </code></pre>
  
  <p>Is this the best way to do it?</p>