title: Select items in second table based on result from first table in MySQL
body: <p>I have two MySQL tables tableA and tableB. In tableA I want to select all zip codes and their respective coordinates using the following query:</p>
  
  <pre><code>SELECT zip,lat,lng
  FROM tableA
  </code></pre>
  
  <p>However, I want to create a one to many relationship and select all items in a second table based on the results from the first table. For example I want to select a list of all locations in tableB that are in each zip code in tableA. Normally I would try to run a query like the following (assuming the zip code is '00000':</p>
  
  <pre><code>SELECT locations
  FROM tableB
  WHERE distanceFormula(tableA.lat,tableA.lng,tableB.lat,tableB.lng) &lt; 50
  </code></pre>
  
  <p>How can I combine these two queries to run the second query for every result in the first query.</p>