0

I have the following Transport table with thousand of records of train and bus stops and airports.

ID       Lon                   Lat                  Name

1        0.37573               51.87968              London Luton Airport
2        0.17486               52.20587              Cambridge Airport
3        0.26251               51.88935              London Stansted Airport

I need to give the mysql query any given lat lon vars for the location I want to check and then I need to list all transport links within a given distance of say 50 miles.

Is this possible with mysql and can some one show me thanks

Barry Connolly
  • 663
  • 1
  • 6
  • 20

1 Answers1

0

Yes it is.

SELECT * FROM stops WHERE SQRT(MAX(Lat,poslat)-MIN(Lat,poslat),MAX(Lon,poslon)-MIN(Lon,poslon)) < 50

Make sure you define poslon and poslat as being the researched position.

  • how efficient is this given tens (or hundreds) of thousands of records? My guess is that mySQL is going to really suffer running this calculation against every location record right? – Yevgeny Simkin Oct 24 '14 at 03:42