 <pre><code>SELECT ACOS(COS(RADIANS(lat)) * COS(RADIANS(lon)) * COS(RADIANS(34.7405350)) * COS(RADIANS(-92.3245120)) + COS(RADIANS(lat)) * SIN(RADIANS(lon)) * COS(RADIANS(34.7405350)) * SIN(RADIANS(-92.3245120)) + SIN(RADIANS(lat)) * SIN(RADIANS(34.7405350))) * 3963.1 AS Distance FROM Stores WHERE 1 HAVING Distance &lt;= 50 </code></pre> <p>Here's how I use it in PHP:</p> <pre><code>// Find rows in Stores within 50 miles of $lat,$lon $lat = '34.7405350'; $lon = '-92.3245120'; $sql = "SELECT Stores.*, ACOS(COS(RADIANS(lat)) * COS(RADIANS(lon)) * COS(RADIANS($lat)) * COS(RADIANS($lon)) + COS(RADIANS(lat)) * SIN(RADIANS(lon)) * COS(RADIANS($lat)) * SIN(RADIANS($lon)) + SIN(RADIANS(lat)) * SIN(RADIANS($lat))) * 3963.1 AS Distance FROM Stores WHERE 1 HAVING Distance &lt;= 50"; </code></pre>