I'm trying to run a SQL query to search for a term and a users location.
Individually each SQL query works fine but together I receive this error #1064 - 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 'AS distance FROM locations HAVING distance < 50 ORDER BY distance LIMIT 0 , ' at line 10
This is the code:
SELECT * FROM `table_name` WHERE `column_name` LIKE '%search_term%' AND *, ( 3959 * acos ( cos ( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($long) ) + sin ( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < 50 ORDER BY distance LIMIT 0 , 20;
أكثر...
Individually each SQL query works fine but together I receive this error #1064 - 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 'AS distance FROM locations HAVING distance < 50 ORDER BY distance LIMIT 0 , ' at line 10
This is the code:
SELECT * FROM `table_name` WHERE `column_name` LIKE '%search_term%' AND *, ( 3959 * acos ( cos ( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($long) ) + sin ( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < 50 ORDER BY distance LIMIT 0 , 20;
أكثر...