Created
July 10, 2019 20:07
-
-
Save rubemlrm/8962c470e228d5f838d943b80aeb0c20 to your computer and use it in GitHub Desktop.
GPS query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT es.county_id, latitude , longitude, | |
IFNULL(tr_county_name.value,co.name) AS countyName, | |
es.name, co.name, co.code | |
FROM hi_establishments as es | |
LEFT JOIN hi_counties as co ON co.id = es.county_id | |
LEFT JOIN hi_translations AS tr_county_name ON tr_county_name.hi_table = 'hi_counties' | |
AND tr_county_name.lang = 'pt' | |
AND tr_county_name.field = 'name' | |
AND tr_county_name.row_id = co.id | |
WHERE valence_id = {$valenceID} | |
GROUP BY countyName | |
HAVING ( | |
3959 * ACOS( | |
COS( | |
RADIANS( | |
{$userCoordinates["latitude"]})) * COS(RADIANS(latitude)) * | |
COS(RADIANS(longitude) - RADIANS({$userCoordinates["longitude"]}) | |
) | |
+ SIN(RADIANS({$userCoordinates["latitude"]})) | |
* SIN(RADIANS(latitude)))) < 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment