Mysql查询显示距离小于100公里的记录

时间:2016-10-18 14:08:07

标签: mysql

I have 2 tables (given sample records):
1> tbl_travel
 ----------------------------------------------------------------------
 |  id     | from_loc| from_lat | from_lon |to_loc |  to_lat | to_lon |
 ----------------------------------------------------------------------
 |  TRV1   | Kolkata |34.44444  | 84.3434  | Dumka |34.44444 | 84.3434|
 ----------------------------------------------------------------------
 |  TRV2   | Vizag   |30.44222  | 83.3412  | Pune  |35.44345 | 85.3411|
 ----------------------------------------------------------------------
 |  TRV3   | Challa  |34.5672   | 82.2345  | Pune  |35.44345 | 85.3411|
 ----------------------------------------------------------------------

1> tbl_agent_route
 ----------------------------------------------------------------------
 |id|agent_id|from_route|from_lat| from_lon |to_route |to_lat|to_lon|
 ----------------------------------------------------------------------
 |1 |2  | Rachi |34.44444  | 84.3434  | Durgapur|34.44444 | 84.3434|
 ----------------------------------------------------------------------
 |2 |2  | Srirampuram |30.44222  | 83.3412  | mumbai  |35.44345 | 85.3411|
 ----------------------------------------------------------------------
 |3 |1  | Dariyapur  |34.5672   | 82.2345  | Rajgir  |35.44345 | 85.3411|
 ----------------------------------------------------------------------

现在我需要旅行代理商路线(from_route或to_route)半径100公里范围内的所有旅行记录,其agent_id为2。

感谢。

0 个答案:

没有答案