If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need help in GEO query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-11, 01:20
mavrick4sky mavrick4sky is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
Question Need help in GEO query

-----
SELECT * , 3956 *2 * ASIN( SQRT( POWER( SIN( ( 122.4058 - ABS( dest.lat ) ) * PI( ) /180 /2 ) , 2 ) + COS( 122.4058 * PI( ) /180 ) * COS( ABS( dest.lat ) * PI( ) /180 ) * POWER( SIN( ( 37.7907 - dest.lon ) * PI( ) /180 /2 ) , 2 ) ) ) AS distance
FROM members dest
HAVING distance <25

Above query run perfectly .. Users will have one field name search_distance .. So i want to calculate users location and current location distance based in search_distance ..

Please help me to solve this ! Let me know if this is not clear


User Table have below fields
id, user_name, lat, lon, search_distance
Reply With Quote
  #2 (permalink)  
Old 12-22-11, 05:00
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
This is not clear. If you are looking for assistance in rewriting the formula or a problem with the database/SQL?
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 12-22-11, 06:36
mavrick4sky mavrick4sky is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
Yes, I need help rewrite query ..This query will search lat,lon inside 25km redius from current location ...

Now I want to add constraint .. Based on searched lat,lon list i want to calculate current location's distance..
Let me know if still not clear ..

Last edited by mavrick4sky; 12-22-11 at 06:40.
Reply With Quote
Reply

Tags
geo distance, join between, mysql, subquery

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On