Advertisement

07.11.2008 at 11:49AM PDT, ID: 23558266 | Points: 500
[x]
Attachment Details

db query syntax question

Asked by ioustinos_sarris in PHP and Databases

Hi there,
I have a table which consists of
id
X
Y

Given the X and Y (of a place) and radius i can get all the records within a certain distance with this query.

How can i achieve the same (optimized in speed) given only the id of a place.

Start Free Trial
1:
2:
3:
4:
5:
6:
$sql_get_collisions = "SELECT 
							id,
							(((acos(sin((".$Y."*pi()/180)) * sin((`Y`*pi()/180))+cos((".$Y."*pi()/180)) * cos((`Y`*pi()/180)) * cos(((".$X."- `X`)*pi()/180)))*180/pi())*60*1.1515*1.609344) as distance
							 
					FROM ".PLACES." 
					HAVING distance <= '".$this->radius."'";
[+][-]07.11.2008 at 11:57AM PDT, ID: 21984990

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2008 at 12:11PM PDT, ID: 21985118

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628