title: Sub Query Problems
body: <p>Im having issues getting my head around how i go about coding the following. I have one table with a list of lat/longitudes and another table with a list of place names with latitudes and longitudes. What i need to do is this : 
  1) Loop through each item in table 1, grab the lat and long, do a radius search on table 2 and grab the place name, update table 1 with the new place name. This code gets me the place name i require : </p>
  
  <pre><code>$sql="SELECT *, (3959 * acos(cos(radians('".$lat."')) * cos(radians(lat)) * cos( radians(lon) - radians('".$lng."')) + sin(radians('".$lat."')) * 
  sin(radians(lat)))) 
  AS distance 
  FROM cats HAVING distance &lt; 5 ORDER BY distance LIMIT 1";
  </code></pre>
  
  <p>I need help figuring out how i join the 2 queries together, or the best way for me to loop through lat/longs from table 1. I tried doing this with a php loop but i dont think thats the best way and i couldn't get it to work </p>
  
  <p>Thanks for any help or suggestions!</p>