Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to get nearest location in mysql with latitude and longitude

SELECT latitude, longitude, address_1, SQRT(
    POW(69.1 * (latitude - [starlat]), 2) +
    POW(69.1 * ([startlng] - longitude) * COS(latitude / 57.3), 2)) AS distance
FROM address HAVING distance < 25 ORDER BY distance

-- where [starlat] and [startlng] is the position where to start measuring the distance.
Comment

PREVIOUS NEXT
Code Example
Sql :: execute stored procedure 
Sql :: remove duplicates sql server select 
Sql :: SQL Remove Index From Tables 
Sql :: ubuntu connect to mssql database 
Sql :: mysqli last row 
Sql :: update mongodb version ubuntu 
Sql :: insert output identity 
Sql :: sql how to duplicate a table 
Sql :: copy table postgres 
Sql :: how to connect to xampp sql server on windows cmd 
Sql :: add column if not exists mysql 
Sql :: pl/sql cursor 
Sql :: oracle create table auto generated primary key 
Sql :: mysql cashing error 
Sql :: concatenate two strings in sql 
Sql :: sql extract numbers from string 
Sql :: cursor.execute in python sqlite3 
Sql :: sql round down to nearest integer 
Sql :: condition in count sql 
Sql :: how to get the date from datetime in mysql 
Sql :: oracle sql select all days between two dates except weekends 
Sql :: sql server insert into select 
Sql :: SQL DEFAULT Constraint With Alter Table 
Sql :: sql table 
Sql :: spring data.sql table not found 
Sql :: sql insert from excel 
Sql :: null sql 
Sql :: mysql check date range 
Sql :: postgresql function 
Sql :: postgresql subtract date/hours 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =