3 messages in com.mysql.lists.mysqlQuery missing rows in location of zip...
FromSent OnAttachments
Steffan A. Cline25 Sep 2006 06:09 
Jay Pipes25 Sep 2006 06:58 
Steffan A. Cline25 Sep 2006 07:08 
Subject:Query missing rows in location of zip by distance
From:Steffan A. Cline (stef@hldns.com)
Date:09/25/2006 06:09:01 AM
List:com.mysql.lists.mysql

Ran into a strange problem. In this zip code I am searching in I know for sure I have 6 locations within the 63385 zip.

Doing a simple select * from locations where zip = '63385' returns 6 rows.

Basically all 6 should come up in the big query because they are within the same zip and that any other locations within the same area. They all have the same latitude and longitude but only 1 shows up.

SELECT b.zip, b.state,b.storename, b.address1, b.address2, b.city, b.state, b.zip, b.id, ROUND((3956 * (2 * ASIN(SQRT( POWER(SIN(((a.lat-b.lat)*0.017453293)/2),2) + COS(a.lat*0.017453293) * COS(b.lat*0.017453293) * POWER(SIN(((a.lon-b.lon)*0.017453293)/2),2))))),2) AS distance FROM zipcodes a, locations b WHERE a.zip = "63385" GROUP BY distance HAVING distance <= 5;

A tough one. I restarted MySQL thinking it could somehow be a bad cache or something but no matter what I only get these results. Now, I did think of cheating and adding an OR zip=63385 but then what would happen if a neighboring zip had 5 locations. I'd probably only get 1 record from that as well. :/

Thanks

Steffan

---------------------------------------------------------------