Hi there I’m really struggling getting the following sql query to work, i apologise in advance if ive made a mash of this but im still learning the full advanced areas of SQL.
Here is my code…
"SELECT *,(((acos(sin((".$latitude."*pi()/180)) *
sin((`latitude`*pi()/180))+cos((".$latitude."*pi()/180)) *
cos((`latitude`*pi()/180)) * cos(((".$longitude."- `longitude`)*pi()/180))))
*180/pi())*60*1.1515) as distance
FROM `locations` l HAVING distance <= '".$distance."' JOIN
(SELECT * users) u
ON (l.id = u.basic_location)
WHERE u.id != A $AND2
ORDER BY distance ASC"
I keep getting the following error message…
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'JOIN (SELECT * users) u ON (l.id = u.basic_location) WHERE u.id' at line 1
Ive tried many combinations of this but ive become stumped and was looking for some help?
JOINshould follow right afterFROM tablenameor anotherJOINWHERE, notHAVINGin this caseJOIN users u, not subquery (in this case it makes no sense)