I have the fallowing mysql query
SELECT de.geoId,(6371 * ACOS( COS( RADIANS(zde.latitude) )*
COS(RADIANS( de.latitude ) ) * COS( RADIANS( de.longitude ) - RADIANS(zde.longitude) ) +
SIN( RADIANS(zde.latitude) ) * SIN( RADIANS( de.latitude ) ) ) ) AS distance
FROM tbl_zipde AS zde
LEFT JOIN tbl_country_de AS de
ON (de.admin1_code=zde.admin_code1)
Where zde.id=8 and de.geoId=24 having distance<1
This query should return a record from table tbl_zountry_de which has the same latitude and longitude values as record with id=8 from tbl_zipde but because the calculated distance between this two points is 0, mysql recognizes 0 as NULL for distance and so it dosen't return any record but if I delete the "having distance<1" then it returns the corect record with id=24 from tbl_country_de but with a NULL value for table column distance.
How should I write the mysql query in order for mysql to return records with distance equal to 0 between (latitude and longitude values) for two points
Why does mysql return NULL for distance instead of '0' ?
I have change the latitude and longitude data type from decimal(10,7) to float(10,7) and I works. Don't know if that was the real problem??
nullis "contagious". if you include a null value in any sort of math operation, the result of the entire operation becomes null. - Marc B