Wednesday, October 22, 2014

Nearest-location finder radius for MySQL

Standard



CREATE TABLE IF NOT EXISTS `location` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `iso` varchar(50) DEFAULT NULL,
  `local_name` varchar(255) DEFAULT NULL,
  `type` char(2) DEFAULT NULL,
  `in_location` int(11) unsigned DEFAULT NULL,
  `geo_lat` double(18,11) DEFAULT NULL,
  `geo_lng` double(18,11) DEFAULT NULL,
  `db_id` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=108477 ;


 INTO `location` (`id`, `iso`, `local_name`, `type`, `in_location`, `geo_lat`, `geo_lng`, `db_id`) VALUES
(244, 'ZA', 'South Africa\r\n', 'CO', NULL, -29.00000000000, 24.00000000000, 'ZA'),
(4379, 'ZA-05', 'Eastern Cape\r', 'RE', 244, NULL, NULL, '4322'),
(4380, 'ZA-03', 'Free State\r', 'RE', 244, NULL, NULL, '4323'),
(4381, 'ZA-06', 'Gauteng\r', 'RE', 244, NULL, NULL, '4324'),
(4382, 'ZA-02', 'KwaZulu-Natal\r', 'RE', 244, NULL, NULL, '4325'),
(4383, 'ZA-09', 'Limpopo\r', 'RE', 244, NULL, NULL, '4326'),
(4384, 'ZA-07', 'Mpumalanga\r', 'RE', 244, NULL, NULL, '4327'),
(4385, 'ZA-10', 'North-West\r', 'RE', 244, NULL, NULL, '4328'),
(4386, 'ZA-08', 'Northern Cape\r', 'RE', 244, NULL, NULL, '4329'),
(4387, 'ZA-11', 'Western Cape\r', 'RE', 244, NULL, NULL, '4330'),
(8689, 'ZA-11-104061', 'Cape Town', 'CI', 4387, -33.91670000000, 18.41670000000, '104061'),
(8690, 'ZA-06-104062', 'Pretoria', 'CI', 4381, -25.70690000000, 28.22940000000, '104062'),
(8691, 'ZA-02-104063', 'Pietermaritzburg', 'CI', 4382, -29.61670000000, 30.38330000000, '104063'),
(8692, 'ZA-10-104064', 'Potchefstroom', 'CI', 4385, -26.71670000000, 27.10000000000, '104064'),
(8693, 'ZA-03-104065', 'Bloemfontein', 'CI', 4380, -29.13330000000, 26.20000000000, '104065'),
(8694, 'ZA-02-104066', 'Durban', 'CI', 4382, -29.85000000000, 31.01670000000, '104066'),
(8695, 'ZA-05-104067', 'Grahamstown', 'CI', 4379, -33.30000000000, 26.53330000000, '104067'),
(8696, 'ZA-11-104068', 'Stellenbosch', 'CI', 4387, -33.93330000000, 18.85000000000, '104068'),
(8697, 'ZA-06-104069', 'Sandton', 'CI', 4381, -26.05000000000, 27.96670000000, '104069'),
(8698, 'ZA-06-104070', 'Johannesburg', 'CI', 4381, -26.20000000000, 28.08330000000, '104070'),
(8699, 'ZA-05-104071', 'Uitenhage', 'CI', 4379, -33.76530000000, 25.40220000000, '104071'),
(8700, 'ZA-06-104072', 'Parkview', 'CI', 4381, -26.16670000000, 28.03330000000, '104072'),
(8701, 'ZA-11-104073', 'Wynberg', 'CI', 4387, -33.98330000000, 18.40000000000, '104073'),
(8702, 'ZA-06-104074', 'Bedfordview', 'CI', 4381, -26.16670000000, 28.15000000000, '104074'),
(8703, 'ZA-11-104075', 'Parow', 'CI', 4387, -33.90000000000, 18.60000000000, '104075'),
(8704, 'ZA-06-104076', 'Vanderbijlpark', 'CI', 4381, -26.70000000000, 27.81670000000, '104076'),
(8705, 'ZA-07-104077', 'Middelburg', 'CI', 4384, -25.78330000000, 29.46670000000, '104077'),
(8706, 'ZA-06-104078', 'Marshalltown', 'CI', 4381, -26.20000000000, 28.08330000000, '104078'),
(8707, 'ZA-05-104079', 'East London', 'CI', 4379, -33.03330000000, 27.91670000000, '104079'),
(8708, 'ZA-06-104080', 'Olifantsfontein', 'CI', 4381, -25.96390000000, 28.23940000000, '104080'),
(8709, 'ZA-06-104081', 'Lynnwood', 'CI', 4381, -25.76170000000, 28.27750000000, '104081'),
(8710, 'ZA-06-104082', 'Rosslyn', 'CI', 4381, -25.62420000000, 28.09420000000, '104082'),
(8711, 'ZA-06-104083', 'Houghton', 'CI', 4381, -26.15000000000, 28.05000000000, '104083'),
(8712, 'ZA-06-104084', 'Silverton', 'CI', 4381, -25.73170000000, 28.33470000000, '104084'),
(8713, 'ZA-11-104085', 'Roggebaai', 'CI', 4387, -33.91670000000, 18.43330000000, '104085'),
(8714, 'ZA-06-104086', 'Midrand', 'CI', 4381, -25.96360000000, 28.13780000000, '104086'),
(8715, 'ZA-05-104087', 'Braamfontein', 'CI', 4379, -31.40000000000, 26.48330000000, '104087'),
(8717, 'ZA-11-104089', 'Waverley', 'CI', 4387, -33.41670000000, 19.23330000000, '104089'),
(8718, 'ZA-06-104090', 'Parktown', 'CI', 4381, -26.16670000000, 28.03330000000, '104090'),
(8719, 'ZA-05-104091', 'Hogsback', 'CI', 4379, -32.58330000000, 26.95000000000, '104091'),
(8720, 'ZA-08-104092', 'Modderfontein', 'CI', 4386, -28.81670000000, 17.16670000000, '104092'),
(8721, 'ZA-02-104093', 'Umhlanga Rocks', 'CI', 4382, -29.71670000000, 31.06670000000, '104093'),
(8726, 'ZA-11-104098', 'Faure', 'CI', 4387, -34.03330000000, 18.73330000000, '104098'),
(8727, 'ZA-05-104099', 'Alice', 'CI', 4379, -32.78330000000, 26.83330000000, '104099'),
(8728, 'ZA-10-104100', 'Medunsa', 'CI', 4385, -25.61890000000, 28.02280000000, '104100'),
(8729, 'ZA-05-104101', 'Port Elizabeth', 'CI', 4379, -33.96670000000, 25.58330000000, '104101'),
(8730, 'ZA-11-104102', 'Elsenburg', 'CI', 4387, -33.85000000000, 18.83330000000, '104102'),
(8731, 'ZA-06-104103', 'Craighall', 'CI', 4381, -26.11670000000, 28.01670000000, '104103'),
(8732, 'ZA-06-104104', 'Randburg', 'CI', 4381, -26.10000000000, 27.98330000000, '104104'),
(8733, 'ZA-06-104105', 'Rivonia', 'CI', 4381, -26.05000000000, 28.05000000000, '104105'),
(8734, 'ZA-11-104106', 'Claremont', 'CI', 4387, -33.98330000000, 18.46670000000, '104106'),
(8735, 'ZA-06-104107', 'Honeydew', 'CI', 4381, -26.06670000000, 27.93330000000, '104107'),
(8736, 'ZA-06-104108', 'Halfway House', 'CI', 4381, -25.98330000000, 28.11670000000, '104108'),
(8737, 'ZA-06-104109', 'Centurion', 'CI', 4381, -25.87440000000, 28.17060000000, '104109'),
(8738, 'ZA-05-104110', 'Umtata', 'CI', 4379, -31.58330000000, 28.78330000000, '104110'),
(8739, 'ZA-02-104111', 'Westville', 'CI', 4382, -29.83330000000, 30.93330000000, '104111'),
(8740, 'ZA-06-104112', 'Boksburg', 'CI', 4381, -26.21670000000, 28.25000000000, '104112'),
(8741, 'ZA-02-104113', 'Pinetown', 'CI', 4382, -29.81670000000, 30.85000000000, '104113'),
(8742, 'ZA-05-104114', 'Doornfontein', 'CI', 4379, -33.10000000000, 24.26670000000, '104114'),
(8743, 'ZA-06-104115', 'Onderstepoort', 'CI', 4381, -25.65060000000, 28.18420000000, '104115'),
(8744, 'ZA-02-104116', 'Greytown', 'CI', 4382, -29.06670000000, 30.58330000000, '104116'),
(8745, 'ZA-02-104117', 'Overport', 'CI', 4382, -29.83330000000, 31.00000000000, '104117'),
(8746, 'ZA-06-104118', 'Krugersdorp', 'CI', 4381, -26.10000000000, 27.76670000000, '104118'),
(8747, 'ZA-06-104119', 'Menlo Park', 'CI', 4381, -25.77110000000, 28.30780000000, '104119'),
(8748, 'ZA-05-104120', 'Korsten', 'CI', 4379, -33.91670000000, 25.56670000000, '104120'),
(8749, 'ZA-11-104121', 'Sunnyside', 'CI', 4387, -33.96670000000, 18.51670000000, '104121'),
(8750, 'ZA-03-104122', 'Roodepoort', 'CI', 4380, -27.16670000000, 28.16670000000, '104122'),
(8791, 'ZA-06-104163', 'Kempton Park', 'CI', 4381, -26.10000000000, 28.25000000000, '104163'),
(8792, 'ZA-05-104164', 'Trust', 'CI', 4379, -31.43330000000, 27.60000000000, '104164'),
(8793, 'ZA-05-104165', 'Walmer', 'CI', 4379, -33.98330000000, 25.58330000000, '104165'),
(8794, 'ZA-11-104166', 'Elandsfontein', 'CI', 4387, -33.16670000000, 19.33330000000, '104166'),
(8795, 'ZA-06-104167', 'Maraisburg', 'CI', 4381, -26.16670000000, 27.93330000000, '104167'),
(8796, 'ZA-06-104168', 'Edenvale', 'CI', 4381, -26.13330000000, 28.18330000000, '104168'),
(8799, 'ZA-05-104171', 'Butterworth', 'CI', 4379, -32.33330000000, 28.15000000000, '104171'),
(8800, 'ZA-11-104172', 'Bellville', 'CI', 4387, -33.90000000000, 18.63330000000, '104172'),
(8801, 'ZA-03-104173', 'Welkom', 'CI', 4380, -27.98330000000, 26.73330000000, '104173'),
(8808, 'ZA-06-104180', 'Isando', 'CI', 4381, -26.15000000000, 28.20000000000, '104180'),
(8810, 'ZA-10-104182', 'Ga-Rankuwa', 'CI', 4385, -25.58830000000, 28.00780000000, '104182'),
(8811, 'ZA-10-104183', 'Mmabatho', 'CI', 4385, -25.85000000000, 25.63330000000, '104183'),
(8812, 'ZA-09-104184', 'Thohoyandou', 'CI', 4383, -22.95000000000, 30.48330000000, '104184'),
(8813, 'ZA-06-104185', 'Ferndale', 'CI', 4381, -26.08330000000, 27.98330000000, '104185'),
(8814, 'ZA-02-104186', 'New Germany', 'CI', 4382, -29.80000000000, 30.88330000000, '104186'),
(8815, 'ZA-02-104187', 'Empangeni', 'CI', 4382, -28.75000000000, 31.90000000000, '104187'),
(8816, 'ZA-06-104188', 'Vereeniging', 'CI', 4381, -26.66670000000, 27.93330000000, '104188'),
(8817, 'ZA-02-104189', 'Martin', 'CI', 4382, -30.85000000000, 30.06670000000, '104189'),
(8818, 'ZA-11-104190', 'Somerset West', 'CI', 4387, -34.08330000000, 18.85000000000, '104190'),
(8819, 'ZA-05-104191', 'Bedford', 'CI', 4379, -32.68330000000, 26.08330000000, '104191'),
(8820, 'ZA-06-104192', 'Bryanston', 'CI', 4381, -26.05000000000, 28.03330000000, '104192'),
(8821, 'ZA-02-104193', 'Kloof', 'CI', 4382, -29.78330000000, 30.83330000000, '104193'),
(8822, 'ZA-11-104194', 'Pinelands', 'CI', 4387, -33.91670000000, 18.50000000000, '104194'),
(8823, 'ZA-06-104195', 'Germiston', 'CI', 4381, -26.21670000000, 28.18330000000, '104195'),
(8824, 'ZA-11-104196', 'Stilbaai', 'CI', 4387, -34.36670000000, 21.41670000000, '104196'),
(8826, 'ZA-09-104198', 'Pietersburg', 'CI', 4383, -23.90000000000, 29.45000000000, '104198'),
(8827, 'ZA-02-104199', 'Newcastle', 'CI', 4382, -27.75000000000, 29.93330000000, '104199'),
(8828, 'ZA-05-104200', 'Beacon Bay', 'CI', 4379, -32.96670000000, 27.95000000000, '104200'),
(8829, 'ZA-05-104201', 'Westering', 'CI', 4379, -33.93780000000, 25.47560000000, '104201'),
(8831, 'ZA-06-104203', 'Waverly', 'CI', 4381, -26.13330000000, 28.08330000000, '104203'),
(8832, 'ZA-07-104204', 'Witbank', 'CI', 4384, -25.86670000000, 29.23330000000, '104204'),
(8833, 'ZA-06-104205', 'Morningside', 'CI', 4381, -26.06670000000, 28.05000000000, '104205'),
(8834, 'ZA-06-104206', 'Primrose', 'CI', 4381, -26.18330000000, 28.16670000000, '104206'),
(8835, 'ZA-11-104207', 'Hout Bay', 'CI', 4387, -34.03330000000, 18.35000000000, '104207'),
(8836, 'ZA-05-104208', 'Lyndhurst', 'CI', 4379, -30.73330000000, 26.50000000000, '104208'),
(8837, 'ZA-11-104209', 'Muizenberg', 'CI', 4387, -34.11670000000, 18.46670000000, '104209'),
(8839, 'ZA-06-104211', 'Monument Park', 'CI', 4381, -25.80000000000, 28.23330000000, '104211'),
(8903, 'ZA-05-104275', 'Peninsula', 'CI', 4379, -31.91670000000, 26.83330000000, '104275'),
(8904, 'ZA-06-104276', 'Soshanguve', 'CI', 4381, -25.51470000000, 28.10810000000, '104276'),
(8907, 'ZA-11-104279', 'Newlands', 'CI', 4387, -33.96670000000, 18.48330000000, '104279'),
(8908, 'ZA-10-104280', 'Atlanta', 'CI', 4385, -25.20000000000, 27.56670000000, '104280'),
(8910, 'ZA-06-104282', 'Parkhurst', 'CI', 4381, -26.13330000000, 28.01670000000, '104282'),
(8911, 'ZA-11-104283', 'New Horizons', 'CI', 4387, -34.05000000000, 23.33330000000, '104283'),
(8912, 'ZA-06-104284', 'Springs', 'CI', 4381, -26.25000000000, 28.46670000000, '104284'),
(8913, 'ZA-11-104285', 'Constantia', 'CI', 4387, -34.01670000000, 18.45000000000, '104285'),
(8916, 'ZA-11-104288', 'Malmesbury', 'CI', 4387, -33.45000000000, 18.73330000000, '104288'),
(8917, 'ZA-11-104289', 'Woodlands', 'CI', 4387, -34.10000000000, 18.38330000000, '104289'),
(8920, 'ZA-09-104292', 'Tzaneen', 'CI', 4383, -23.83330000000, 30.16670000000, '104292'),
(8921, 'ZA-11-104293', 'Mowbray', 'CI', 4387, -33.93330000000, 18.46670000000, '104293'),
(8922, 'ZA-11-104294', 'Rosebank', 'CI', 4387, -33.95000000000, 18.46670000000, '104294'),
(8923, 'ZA-05-104295', 'Riebeek', 'CI', 4379, -31.66670000000, 25.91670000000, '104295'),
(8924, 'ZA-11-104296', 'Oudtshoorn', 'CI', 4387, -33.58330000000, 22.20000000000, '104296'),
(8925, 'ZA-11-104297', 'Edgemead', 'CI', 4387, -33.88330000000, 18.53330000000, '104297'),
(8926, 'ZA-06-104298', 'Hatfield', 'CI', 4381, -25.74670000000, 28.22310000000, '104298'),
(8927, 'ZA-06-104299', 'Capital Park', 'CI', 4381, -25.72750000000, 28.20170000000, '104299'),
(8928, 'ZA-07-104300', 'Nelspruit', 'CI', 4384, -25.46670000000, 30.96670000000, '104300'),
(8929, 'ZA-03-104301', 'Fichardtpark', 'CI', 4380, -29.13330000000, 26.18330000000, '104301'),
(8930, 'ZA-06-104302', 'Northcliff', 'CI', 4381, -26.13330000000, 27.95000000000, '104302'),
(8931, 'ZA-11-104303', 'Bishopscourt', 'CI', 4387, -33.98330000000, 18.45000000000, '104303'),
(8932, 'ZA-06-104304', 'Laudium', 'CI', 4381, -25.78330000000, 28.10000000000, '104304'),
(8933, 'ZA-06-104305', 'Garsfontein', 'CI', 4381, -25.80080000000, 28.29560000000, '104305'),
(8934, 'ZA-03-104306', 'Lusaka', 'CI', 4380, -29.15000000000, 26.76670000000, '104306'),
(8935, 'ZA-08-104307', 'Campbell', 'CI', 4386, -28.80000000000, 23.70000000000, '104307'),
(8936, 'ZA-07-104308', 'Weltevreden', 'CI', 4384, -25.33330000000, 30.56670000000, '104308'),
(8937, 'ZA-06-104309', 'Westdene', 'CI', 4381, -26.16670000000, 27.98330000000, '104309'),
(8938, 'ZA-09-104310', 'Messina', 'CI', 4383, -22.35000000000, 30.05000000000, '104310'),
(8939, 'ZA-06-104311', 'Benoni', 'CI', 4381, -26.18330000000, 28.31670000000, '104311'),
(8940, 'ZA-02-104312', 'Mount Edgecombe', 'CI', 4382, -29.70000000000, 31.03330000000, '104312'),
(8941, 'ZA-11-104313', 'Sauer', 'CI', 4387, -32.85000000000, 18.56670000000, '104313'),
(8942, 'ZA-10-104314', 'Rustenburg', 'CI', 4385, -25.66670000000, 27.25000000000, '104314'),
(8943, 'ZA-05-104315', 'North End', 'CI', 4379, -33.93330000000, 25.60000000000, '104315'),
(8944, 'ZA-05-104316', 'Emerald Hill', 'CI', 4379, -34.00000000000, 25.55000000000, '104316'),
(8945, 'ZA-02-104317', 'Mobeni', 'CI', 4382, -29.95000000000, 30.95000000000, '104317'),
(8946, 'ZA-05-104318', 'Huguenot', 'CI', 4379, -31.08330000000, 26.60000000000, '104318'),
(8947, 'ZA-10-104319', 'Brits', 'CI', 4385, -25.63330000000, 27.78330000000, '104319'),
(8948, 'ZA-02-104320', 'Port Shepstone', 'CI', 4382, -30.75000000000, 30.45000000000, '104320'),
(8949, 'ZA-05-104321', 'Kwa-Zulu', 'CI', 4379, -31.43330000000, 29.40000000000, '104321'),
(8950, 'ZA-02-104322', 'La Lucia', 'CI', 4382, -29.73330000000, 31.05000000000, '104322'),
(8952, 'ZA-07-104324', 'London', 'CI', 4384, -24.76670000000, 30.86670000000, '104324'),
(8954, 'ZA-03-104326', 'Juta', 'CI', 4380, -30.25000000000, 26.66670000000, '104326'),
(8955, 'ZA-03-104327', 'Florida', 'CI', 4380, -29.93330000000, 26.15000000000, '104327'),
(8968, 'ZA-06-104340', 'Brakpan', 'CI', 4381, -26.23330000000, 28.36670000000, '104340'),
(8969, 'ZA-05-104341', 'Zwartkop', 'CI', 4379, -33.86670000000, 25.60000000000, '104341'),
(8970, 'ZA-06-104342', 'Fairland', 'CI', 4381, -26.13330000000, 27.90000000000, '104342'),
(8971, 'ZA-07-104343', 'Ermelo', 'CI', 4384, -26.53330000000, 29.98330000000, '104343'),
(8999, 'ZA-06-104371', 'Sandhurst', 'CI', 4381, -26.11670000000, 28.05000000000, '104371'),
(9006, 'ZA-11-104378', 'Green Point', 'CI', 4387, -33.91670000000, 18.40000000000, '104378'),
(9016, 'ZA-10-104388', 'Klerksdorp', 'CI', 4385, -26.86670000000, 26.66670000000, '104388'),
(9017, 'ZA-11-104389', 'Lansdowne', 'CI', 4387, -33.98330000000, 18.50000000000, '104389'),
(9018, 'ZA-02-104390', 'Point', 'CI', 4382, -29.86670000000, 31.05000000000, '104390'),
(9019, 'ZA-06-104391', 'Sandown', 'CI', 4381, -26.10000000000, 28.06670000000, '104391'),
(19801, 'ZA-11-115173', 'Mossel Bay', 'CI', 4387, -34.18330000000, 22.13330000000, '115173'),
(22309, 'ZA-11-117681', 'Paarl', 'CI', 4387, -33.73330000000, 18.96670000000, '117681'),
(22943, 'ZA-02-118315', 'Richards Bay', 'CI', 4382, -28.80000000000, 32.10000000000, '118315'),
(22944, 'ZA-11-118316', 'Brooklyn', 'CI', 4387, -33.91670000000, 18.48330000000, '118316'),
(22945, 'ZA-11-118317', 'Montana', 'CI', 4387, -33.41670000000, 19.21670000000, '118317'),
(22946, 'ZA-06-118318', 'Alberton', 'CI', 4381, -26.23330000000, 28.13330000000, '118318'),
(25264, 'ZA-05-120636', 'Waterkloof', 'CI', 4379, -31.68330000000, 26.05000000000, '120636'),
(25319, 'ZA-11-120691', 'Rawsonville', 'CI', 4387, -33.68330000000, 19.31670000000, '120691'),
(29957, 'ZA-11-125329', 'Wellington', 'CI', 4387, -33.63330000000, 19.00000000000, '125329'),
(30097, 'ZA-02-125469', 'Sherwood', 'CI', 4382, -29.83330000000, 30.98330000000, '125469'),
(30219, 'ZA-03-125591', 'Arlington', 'CI', 4380, -28.03330000000, 27.85000000000, '125591'),
(30583, 'ZA-09-125955', 'Windhoek', 'CI', 4383, -24.41670000000, 30.03330000000, '125955'),
(30842, 'ZA-05-126214', 'Melrose', 'CI', 4379, -33.43330000000, 25.95000000000, '126214'),
(30849, 'ZA-06-126221', 'Dunkeld', 'CI', 4381, -26.13330000000, 28.05000000000, '126221'),
(30879, 'ZA-02-126251', 'Jacobs', 'CI', 4382, -29.91670000000, 30.98330000000, '126251'),
(31026, 'ZA-05-126398', 'Horton', 'CI', 4379, -33.10000000000, 27.01670000000, '126398'),
(32666, 'ZA-06-128038', 'Alrode', 'CI', 4381, -26.30000000000, 28.13330000000, '128038'),
(32677, 'ZA-01-128049', 'Content', 'CI', 244, -28.23330000000, 24.85000000000, '128049'),
(33200, 'ZA-03-128572', 'Alfa', 'CI', 4380, -29.56670000000, 25.60000000000, '128572'),
(33267, 'ZA-08-128639', 'Upington', 'CI', 4386, -28.45000000000, 21.25000000000, '128639'),
(33294, 'ZA-11-128666', 'Saldanha', 'CI', 4387, -33.01670000000, 17.95000000000, '128666'),
(34003, 'ZA-05-129375', 'Union', 'CI', 4379, -31.40000000000, 28.15000000000, '129375'),
(34717, 'ZA-11-130089', 'Caledon', 'CI', 4387, -34.21670000000, 19.41670000000, '130089'),
(34915, 'ZA-03-130287', 'Villiers', 'CI', 4380, -27.03330000000, 28.60000000000, '130287'),
(35167, 'ZA-08-130539', 'Jackson', 'CI', 4386, -29.33330000000, 21.06670000000, '130539'),
(36182, 'ZA-11-131554', 'Brackenfell', 'CI', 4387, -33.86670000000, 18.68330000000, '131554'),
(36207, 'ZA-06-131579', 'Randfontein', 'CI', 4381, -26.16670000000, 27.70000000000, '131579'),
(36444, 'ZA-06-131816', 'Booysens', 'CI', 4381, -26.23330000000, 28.01670000000, '131816'),
(36989, 'ZA-05-132361', 'Outspan', 'CI', 4379, -30.71670000000, 26.76670000000, '132361'),
(38428, 'ZA-07-133800', 'Loding', 'CI', 4384, -25.10000000000, 28.76670000000, '133800'),
(41024, 'ZA-02-136396', 'Merebank', 'CI', 4382, -29.96670000000, 30.96670000000, '136396'),
(41479, 'ZA-05-136851', 'Main', 'CI', 4379, -31.90000000000, 27.95000000000, '136851'),
(43106, 'ZA-11-138478', 'Tokai', 'CI', 4387, -34.06670000000, 18.43330000000, '138478'),
(45030, 'ZA-06-140402', 'Cullinan', 'CI', 4381, -25.67560000000, 28.52220000000, '140402'),
(46865, 'ZA-11-142237', 'Milnerton', 'CI', 4387, -33.86670000000, 18.48330000000, '142237'),
(49808, 'ZA-08-145180', 'Sishen', 'CI', 4386, -27.78330000000, 22.98330000000, '145180'),
(49809, 'ZA-03-145181', 'Grootgeluk', 'CI', 4380, -29.43330000000, 25.98330000000, '145181'),
(51762, 'ZA-11-147134', 'Kaapstad', 'CI', 4387, -33.91670000000, 18.41670000000, '147134'),
(52560, 'ZA-05-147932', 'Bell', 'CI', 4379, -33.25000000000, 27.35000000000, '147932'),
(62618, 'ZA-02-157990', 'Hammarsdale', 'CI', 4382, -29.80000000000, 30.65000000000, '157990'),
(62794, 'ZA-10-158166', 'Avon', 'CI', 4385, -26.53330000000, 22.96670000000, '158166'),
(65181, 'ZA-02-160553', 'Victoria', 'CI', 4382, -29.58330000000, 31.13330000000, '160553'),
(85694, 'ZA-11-181066', 'Lakeside', 'CI', 4387, -34.08330000000, 18.45000000000, '181066'),
(85696, 'ZA-07-181068', 'Nooitgedacht', 'CI', 4384, -25.03330000000, 30.43330000000, '181068'),
(85721, 'ZA-06-181093', 'Kew', 'CI', 4381, -26.11670000000, 28.08330000000, '181093'),
(85963, 'ZA-06-181335', 'Northdene Estate', 'CI', 4381, -26.03330000000, 28.08330000000, '181335'),
(85970, 'ZA-11-181342', 'Danga', 'CI', 4387, -33.95000000000, 18.51670000000, '181342'),
(85987, 'ZA-03-181359', 'Langlaagte', 'CI', 4380, -29.88330000000, 26.11670000000, '181359'),
(88785, 'ZA-06-184157', 'Bronkhorstspruit', 'CI', 4381, -25.80830000000, 28.74060000000, '184157'),
(88800, 'ZA-11-184172', 'Steenberg', 'CI', 4387, -34.06670000000, 18.46670000000, '184172'),
(88801, 'ZA-11-184173', 'Knysna', 'CI', 4387, -34.03330000000, 23.03330000000, '184173'),
(88802, 'ZA-06-184174', 'Verwoerdburg', 'CI', 4381, -25.87440000000, 28.17060000000, '184174'),
(88832, 'ZA-11-184204', 'Atlantis', 'CI', 4387, -33.56670000000, 18.48330000000, '184204'),
(88833, 'ZA-06-184205', 'Westonaria', 'CI', 4381, -26.31670000000, 27.65000000000, '184205'),
(88834, 'ZA-11-184206', 'George', 'CI', 4387, -33.96670000000, 22.45000000000, '184206'),
(88835, 'ZA-06-184207', 'Lyttelton', 'CI', 4381, -25.83330000000, 28.21670000000, '184207'),
(88836, 'ZA-11-184208', 'Melkbosstrand', 'CI', 4387, -33.73060000000, 18.43610000000, '184208'),
(88837, 'ZA-06-184209', 'Tembisa', 'CI', 4381, -25.99890000000, 28.22690000000, '184209'),
(88838, 'ZA-07-184210', 'Delmas', 'CI', 4384, -26.15000000000, 28.68330000000, '184210'),
(88839, 'ZA-11-184211', 'Worcester', 'CI', 4387, -33.65000000000, 19.43330000000, '184211'),
(88840, 'ZA-11-184212', 'Grabouw', 'CI', 4387, -34.15000000000, 19.01670000000, '184212'),
(88841, 'ZA-11-184213', 'Kingfisher Creek', 'CI', 4387, -34.01670000000, 22.80000000000, '184213'),
(88842, 'ZA-11-184214', 'Velddrift', 'CI', 4387, -32.78330000000, 18.16670000000, '184214'),
(88843, 'ZA-07-184215', 'Balfour', 'CI', 4384, -26.65000000000, 28.58330000000, '184215'),
(88844, 'ZA-06-184216', 'Soweto', 'CI', 4381, -26.26670000000, 27.86670000000, '184216'),
(88845, 'ZA-10-184217', 'Fochville', 'CI', 4385, -26.48330000000, 27.50000000000, '184217'),
(88846, 'ZA-02-184218', 'Escombe', 'CI', 4382, -29.86670000000, 30.90000000000, '184218'),
(88847, 'ZA-02-184219', 'Umkomaas', 'CI', 4382, -30.20000000000, 30.80000000000, '184219'),
(88848, 'ZA-02-184220', 'Situndu', 'CI', 4382, -29.88330000000, 30.81670000000, '184220'),
(88849, 'ZA-02-184221', 'Scottsburgh', 'CI', 4382, -30.28330000000, 30.75000000000, '184221'),
(88850, 'ZA-02-184222', 'Vryheid', 'CI', 4382, -27.76670000000, 30.80000000000, '184222'),
(88851, 'ZA-02-184223', 'Emberton', 'CI', 4382, -29.78330000000, 30.80000000000, '184223'),
(88852, 'ZA-02-184224', 'Forest Hills', 'CI', 4382, -29.75000000000, 30.81670000000, '184224'),
(88853, 'ZA-02-184225', 'KwaNdengezi', 'CI', 4382, -29.85000000000, 30.78330000000, '184225'),
(88854, 'ZA-02-184226', 'Hillcrest', 'CI', 4382, -29.76670000000, 30.76670000000, '184226'),
(88855, 'ZA-02-184227', 'Droogdal', 'CI', 4382, -28.11670000000, 29.88330000000, '184227'),
(88856, 'ZA-02-184228', 'Gillitts', 'CI', 4382, -29.80000000000, 30.80000000000, '184228'),
(88857, 'ZA-02-184229', 'Gologodo', 'CI', 4382, -29.98330000000, 30.83330000000, '184229'),
(88858, 'ZA-02-184230', 'Glencoe', 'CI', 4382, -28.18330000000, 30.15000000000, '184230'),
(88859, 'ZA-02-184231', 'Chatsworth 1', 'CI', 4382, -29.91670000000, 30.90000000000, '184231'),
(88860, 'ZA-02-184232', 'Matatiele', 'CI', 4382, -30.33330000000, 28.80000000000, '184232'),
(88861, 'ZA-05-184233', 'Queenstown', 'CI', 4379, -31.90000000000, 26.88330000000, '184233'),
(88862, 'ZA-07-184234', 'Witrivier', 'CI', 4384, -25.31670000000, 31.01670000000, '184234'),
(88863, 'ZA-11-184235', 'Hermanus', 'CI', 4387, -34.41670000000, 19.23330000000, '184235'),
(88864, 'ZA-03-184236', 'Deneysville', 'CI', 4380, -26.88330000000, 28.10000000000, '184236'),
(88865, 'ZA-03-184237', 'Brandfort', 'CI', 4380, -28.70000000000, 26.46670000000, '184237'),
(88866, 'ZA-03-184238', 'Bethlehem', 'CI', 4380, -28.23330000000, 28.30000000000, '184238'),
(88867, 'ZA-07-184239', 'Kriel', 'CI', 4384, -26.26670000000, 29.23330000000, '184239'),
(88868, 'ZA-10-184240', 'Hartbeespoort', 'CI', 4385, -25.73330000000, 27.85000000000, '184240'),
(88869, 'ZA-10-184241', 'Temba', 'CI', 4385, -25.36500000000, 28.21890000000, '184241'),
(88870, 'ZA-07-184242', 'Rietkuil', 'CI', 4384, -25.95000000000, 29.78330000000, '184242'),
(88871, 'ZA-07-184243', 'Komatipoort', 'CI', 4384, -25.43330000000, 31.93330000000, '184243'),
(88872, 'ZA-02-184244', 'Sundumbili', 'CI', 4382, -29.13330000000, 31.40000000000, '184244'),
(88873, 'ZA-02-184245', 'Umlazi', 'CI', 4382, -29.96670000000, 30.88330000000, '184245'),
(88874, 'ZA-02-184246', 'Ballitoville', 'CI', 4382, -29.55000000000, 31.20000000000, '184246'),
(88875, 'ZA-02-184247', 'Empembeni', 'CI', 4382, -28.83330000000, 31.98330000000, '184247'),
(88876, 'ZA-02-184248', 'Stanger', 'CI', 4382, -29.33330000000, 31.30000000000, '184248'),
(88877, 'ZA-02-184249', 'Eshowe', 'CI', 4382, -28.88330000000, 31.46670000000, '184249'),
(88878, 'ZA-02-184250', 'Malukaze', 'CI', 4382, -29.98330000000, 30.88330000000, '184250'),
(88879, 'ZA-02-184251', 'Tongaat', 'CI', 4382, -29.58330000000, 31.13330000000, '184251'),
(88880, 'ZA-06-184252', 'Nigel', 'CI', 4381, -26.41670000000, 28.46670000000, '184252'),
(88881, 'ZA-05-184253', 'Bisho', 'CI', 4379, -32.86670000000, 27.43330000000, '184253'),
(88882, 'ZA-11-184254', 'Sedgefield', 'CI', 4387, -34.01670000000, 22.80000000000, '184254'),
(88883, 'ZA-11-184255', 'Bothastrand', 'CI', 4387, -34.05000000000, 22.26670000000, '184255'),
(88884, 'ZA-11-184256', 'Heroldsbaai', 'CI', 4387, -34.05000000000, 22.38330000000, '184256'),
(92964, 'ZA-07-188336', 'Malelane', 'CI', 4384, -25.48330000000, 31.51670000000, '188336'),
(106354, 'ZA-06-201726', 'Weltevredenpark', 'CI', 4381, -26.11670000000, 27.93330000000, '201726'),
(106560, 'ZA-07-201932', 'Standerton', 'CI', 4384, -26.95000000000, 29.25000000000, '201932'),
(106561, 'ZA-03-201933', 'Kroonstad', 'CI', 4380, -27.65000000000, 27.23330000000, '201933'),
(106562, 'ZA-03-201934', 'Reitz', 'CI', 4380, -27.80000000000, 28.43330000000, '201934'),
(106563, 'ZA-08-201935', 'Kimberley', 'CI', 4386, -28.73330000000, 24.76670000000, '201935'),
(106564, 'ZA-08-201936', 'Warrenton', 'CI', 4386, -28.11670000000, 24.85000000000, '201936'),
(106565, 'ZA-08-201937', 'Springbok', 'CI', 4386, -29.66670000000, 17.88330000000, '201937'),
(106566, 'ZA-02-201938', 'Winklespruit', 'CI', 4382, -30.10000000000, 30.85000000000, '201938'),
(106567, 'ZA-11-201939', 'Bovenfontein', 'CI', 4387, -33.13330000000, 18.33330000000, '201939'),
(106568, 'ZA-05-201940', 'Stutterheim', 'CI', 4379, -32.56670000000, 27.41670000000, '201940'),
(106569, 'ZA-05-201941', 'Graaff-Reinet', 'CI', 4379, -32.25000000000, 24.55000000000, '201941'),
(106570, 'ZA-05-201942', 'Kruisfontein', 'CI', 4379, -34.00000000000, 24.73330000000, '201942'),
(106571, 'ZA-05-201943', 'Kirkwood', 'CI', 4379, -33.41560000000, 25.44360000000, '201943'),
(106572, 'ZA-11-201944', 'Swellendam', 'CI', 4387, -34.03330000000, 20.43330000000, '201944'),
(106573, 'ZA-09-201945', 'Giyani', 'CI', 4383, -23.31670000000, 30.71670000000, '201945'),
(106574, 'ZA-09-201946', 'Duiwelskloof', 'CI', 4383, -23.70000000000, 30.13330000000, '201946'),
(106575, 'ZA-09-201947', 'Thabazimbi', 'CI', 4383, -24.60000000000, 27.40000000000, '201947'),
(106576, 'ZA-07-201948', 'Secunda', 'CI', 4384, -26.55000000000, 29.16670000000, '201948'),
(106577, 'ZA-07-201949', 'Belfast', 'CI', 4384, -25.68330000000, 30.03330000000, '201949'),
(106578, 'ZA-07-201950', 'De Hoop', 'CI', 4384, -24.96670000000, 29.95000000000, '201950'),
(106579, 'ZA-02-201951', 'Utrecht', 'CI', 4382, -27.65000000000, 30.33330000000, '201951'),
(106580, 'ZA-02-201952', 'Margate', 'CI', 4382, -30.85000000000, 30.36670000000, '201952'),
(106581, 'ZA-02-201953', 'Richmond', 'CI', 4382, -29.86670000000, 30.26670000000, '201953'),
(106582, 'ZA-02-201954', 'Ladysmith', 'CI', 4382, -28.55000000000, 29.78330000000, '201954'),
(106583, 'ZA-02-201955', 'Estcourt', 'CI', 4382, -29.00000000000, 29.88330000000, '201955'),
(106584, 'ZA-07-201956', 'Moolman', 'CI', 4384, -27.15000000000, 30.86670000000, '201956'),
(106585, 'ZA-07-201957', 'Piet Retief', 'CI', 4384, -27.00000000000, 30.80000000000, '201957'),
(106666, 'ZA-10-202038', 'Leeudoringstad', 'CI', 4385, -27.23330000000, 26.23330000000, '202038'),
(106726, 'ZA-03-202098', 'Virginia', 'CI', 4380, -28.11670000000, 26.90000000000, '202098'),
(106727, 'ZA-03-202099', 'Kraalfontein', 'CI', 4380, -30.35000000000, 26.05000000000, '202099'),
(106754, 'ZA-02-202126', 'Botha''s Hill', 'CI', 4382, -29.71670000000, 30.73330000000, '202126'),
(106755, 'ZA-11-202127', 'Durbanville', 'CI', 4387, -33.83330000000, 18.65000000000, '202127'),
(106756, 'ZA-06-202128', 'Strathavon', 'CI', 4381, -26.10000000000, 28.06670000000, '202128'),
(106757, 'ZA-05-202129', 'Cambridge', 'CI', 4379, -32.96670000000, 27.88330000000, '202129'),
(106758, 'ZA-11-202130', 'Bothasig', 'CI', 4387, -33.85000000000, 18.55000000000, '202130'),
(106759, 'ZA-11-202131', 'Still Bay', 'CI', 4387, -34.36670000000, 21.41670000000, '202131'),
(106760, 'ZA-11-202132', 'Melkhoutfontein', 'CI', 4387, -34.30000000000, 21.81670000000, '202132'),
(106762, 'ZA-06-202134', 'Boskruin', 'CI', 4381, -26.08330000000, 27.95000000000, '202134'),
(106763, 'ZA-03-202135', 'Ladybrand', 'CI', 4380, -29.20000000000, 27.45000000000, '202135'),
(106764, 'ZA-06-202136', 'Little Falls', 'CI', 4381, -26.11670000000, 27.88330000000, '202136'),
(106765, 'ZA-11-202137', 'Kensington', 'CI', 4387, -33.91670000000, 18.50000000000, '202137'),
(106766, 'ZA-11-202138', 'Strand', 'CI', 4387, -34.11670000000, 18.83330000000, '202138'),
(106767, 'ZA-11-202139', 'Goodwood', 'CI', 4387, -33.90000000000, 18.55000000000, '202139'),
(106768, 'ZA-05-202140', 'Doringkloof', 'CI', 4379, -33.61670000000, 26.00000000000, '202140'),
(108328, 'ZA-06-203700', 'Wingate Park', 'CI', 4381, -25.83330000000, 28.25000000000, '203700'),
(108329, 'ZA-02-203701', 'Mtubatuba', 'CI', 4382, -28.41670000000, 32.18330000000, '203701'),
(108330, 'ZA-11-203702', 'Elsiesrivier', 'CI', 4387, -33.91670000000, 18.56670000000, '203702'),
(108331, 'ZA-01-203703', 'Barkly West', 'CI', 244, -28.53330000000, 24.51670000000, '203703'),
(108376, 'ZA-02-203748', 'KwaPheshe', 'CI', 4382, -29.88330000000, 30.01670000000, '203748'),
(108377, 'ZA-07-203749', 'Bethal', 'CI', 4384, -26.43330000000, 29.46670000000, '203749'),
(108378, 'ZA-05-203750', 'Cliffdale', 'CI', 4379, -30.93330000000, 29.46670000000, '203750'),
(108379, 'ZA-02-203751', 'Colenso', 'CI', 4382, -28.73330000000, 29.81670000000, '203751'),
(108380, 'ZA-02-203752', 'Winston Park', 'CI', 4382, -29.81670000000, 30.78330000000, '203752'),
(108381, 'ZA-06-203753', 'Ekangala', 'CI', 4381, -25.69440000000, 28.74830000000, '203753'),
(108382, 'ZA-10-203754', 'Lichtenburg', 'CI', 4385, -26.15000000000, 26.16670000000, '203754'),
(108383, 'ZA-09-203755', 'Nylstroom', 'CI', 4383, -24.70000000000, 28.40000000000, '203755'),
(108384, 'ZA-09-203756', 'Xanthia', 'CI', 4383, -24.83330000000, 31.15000000000, '203756'),
(108385, 'ZA-05-203757', 'Aliwal North', 'CI', 4379, -30.70000000000, 26.70000000000, '203757'),
(108386, 'ZA-02-203758', 'Pinelands', 'CI', 4382, -29.83330000000, 30.85000000000, '203758'),
(108387, 'ZA-11-203759', 'Wilderness', 'CI', 4387, -33.96670000000, 22.56670000000, '203759'),
(108388, 'ZA-02-203760', 'Bergville', 'CI', 4382, -28.73330000000, 29.36670000000, '203760'),
(108389, 'ZA-03-203761', 'Allanridge', 'CI', 4380, -27.75000000000, 26.66670000000, '203761'),
(108390, 'ZA-06-203762', 'Fontainbleau', 'CI', 4381, -26.08330000000, 27.96670000000, '203762'),
(108391, 'ZA-09-203763', 'Hoedspruit', 'CI', 4383, -24.35000000000, 30.96670000000, '203763'),
(108392, 'ZA-02-203764', 'Shelly Beach', 'CI', 4382, -30.80000000000, 30.41670000000, '203764'),
(108393, 'ZA-06-203765', 'Roosevelt Park', 'CI', 4381, -26.15000000000, 27.98330000000, '203765'),
(108394, 'ZA-03-203766', 'Wesselsbron', 'CI', 4380, -27.85000000000, 26.36670000000, '203766'),
(108395, 'ZA-02-203767', 'Howick', 'CI', 4382, -29.46670000000, 30.23330000000, '203767'),
(108396, 'ZA-02-203768', 'Nottingham Road', 'CI', 4382, -29.35000000000, 29.98330000000, '203768'),
(108422, 'ZA-11-203794', 'Ceres', 'CI', 4387, -33.36670000000, 19.31670000000, '203794'),
(108423, 'ZA-11-203795', 'Cravenby', 'CI', 4387, -33.91670000000, 18.60000000000, '203795'),
(108424, 'ZA-11-203796', 'Kuils River', 'CI', 4387, -33.93330000000, 18.66670000000, '203796'),
(108425, 'ZA-02-203797', 'Mpumalanga', 'CI', 4382, -27.88330000000, 31.53330000000, '203797'),
(108426, 'ZA-09-203798', 'Letsitele', 'CI', 4383, -23.88330000000, 30.40000000000, '203798'),
(108427, 'ZA-11-203799', 'Vredendal', 'CI', 4387, -31.66670000000, 18.50000000000, '203799'),
(108428, 'ZA-02-203800', 'Inanda Seminary', 'CI', 4382, -29.71670000000, 30.91670000000, '203800'),
(108429, 'ZA-02-203801', 'Phoenix', 'CI', 4382, -29.71670000000, 31.01670000000, '203801'),
(108430, 'ZA-11-203802', 'Bayview', 'CI', 4387, -34.13330000000, 22.10000000000, '203802'),
(108431, 'ZA-11-203803', 'Hermon', 'CI', 4387, -33.43330000000, 18.96670000000, '203803'),
(108432, 'ZA-11-203804', 'Plettenberg Bay', 'CI', 4387, -34.05000000000, 23.36670000000, '203804'),
(108433, 'ZA-07-203805', 'Graskop', 'CI', 4384, -24.93330000000, 30.83330000000, '203805'),
(108443, 'ZA-09-203815', 'Phalaborwa', 'CI', 4383, -23.95000000000, 31.11670000000, '203815'),
(108448, 'ZA-07-203820', 'Damwal', 'CI', 4384, -25.40000000000, 29.35000000000, '203820'),
(108449, 'ZA-11-203821', 'Napier', 'CI', 4387, -34.46670000000, 19.90000000000, '203821'),
(108450, 'ZA-03-203822', 'Harrismith', 'CI', 4380, -28.28330000000, 29.13330000000, '203822'),
(108451, 'ZA-05-203823', 'Port Alfred', 'CI', 4379, -33.60000000000, 26.90000000000, '203823'),
(108452, 'ZA-02-203824', 'Didini', 'CI', 4382, -30.01670000000, 30.68330000000, '203824'),
(108453, 'ZA-03-203825', 'Petrus Steyn', 'CI', 4380, -27.65000000000, 28.13330000000, '203825'),
(108454, 'ZA-03-203826', 'Heilbron', 'CI', 4380, -27.28330000000, 27.96670000000, '203826'),
(108455, 'ZA-10-203827', 'Hellsgate', 'CI', 4385, -25.88330000000, 25.75000000000, '203827'),
(108471, 'ZA-02-203843', 'Umzumbe', 'CI', 4382, -30.61670000000, 30.55000000000, '203843'),
(108476, 'ZA-06-203848', 'Elsburg', 'CI', 4381, -26.23330000000, 28.20000000000, '203848');



SELECT *, ( 3959 * acos(
  cos( radians(-29.0) )
 * cos( radians( geo_lat ) )
 * cos( radians( geo_lng ) - radians(24.0) )
 + sin( radians(-29.0) )
 * sin( radians( geo_lat ) )
) ) AS distance FROM location HAVING distance < 100
 ORDER BY distance LIMIT 0 , 20

//                 SELECT ListingId, ( 3959 * acos(  
//  cos( radians(6.936088854160977) )  
// * cos( radians( Latitude ) )  
// * cos( radians( Longitude ) - radians(79.8515602254563) )  
// + sin( radians(6.936088854160977) )  
// * sin( radians( Latitude ) )  
//) ) AS distance FROM listings HAVING distance < 100
//ORDER BY `distance` LIMIT 0 , 10

change HAVING distance < 100 to get defferent out put
      

1 comment: