Distance based query advice
<p>Ok its been a while since iv had to do something of this complexity and I'm a little bit stumped.</p>

<p>I have a library class that takes in a postcode and returns an associative array of postcodes in a radius of the entered postcode with the postcode as the key and distance from the original postcode as the value.</p>

<p>example : FK27DJ => 0.094146570284875</p>

<p>The web application is a takeaway restaurant finder and I need to run a query that will find the closest takeaways of each type to the the entered postcode.</p>

<p>There are 4 types of takeaway based on a takeaway_type_id field. So if the user enters their own postcode a single takeaway of each type will be presented to them which is also the closest takeaway of that type to the entered postcode.</p>

<p>So I will need to pass in the array of postcodes from the library class and search the takeaways table for the closest takeaways of each type.</p>

<p>Does this make sense?</p>

<p>The takeaways table contains the following relevant fields:</p>

<p>id(int), takeaway_type_id(int), postcode</p>

<p>Could this be done in a single query? The site is php based.</p>
