10 seconds of searching on Google seems to indicate that the SQUARE() function is a MSSQL function. It may not be implemented or at least not implemented under the same name in or database management systems such as MySQL. The being said, I would be a bit surprised that there is not a similar function available.
How ever your logic should properly do the same thing since yes squaring a function would be to just multiple it by itself. I would just carefully work through all your parenthesis sets to make sure all the functions are being evaluated in the exact order you need them to be.
As for not getting the results you want,
It was many many moons, at least a couple of years ago, I read a long article about doing this type
That would explain why everytime I searched for "mysql square" I was returned junky results!
Yea, I don't know why my results are so inaccurate. Ill search 20002 as a zip code and it wont return 20007 as a close zipcode even though its about a mile away, yet it will return NJ zip codes 25 miles away. Strange. I will continue looking into the accuracy issue and see if there are any updated methods of doing this.
Thanks for the help!
I suggest that you look closely at the MySQL function library reference material for the version of MySQL that you are running ... and, consider upgrading if you need to.
- In any case, you might be able to get more precision by asking for it, e.g. with the CAST() and CONVERT() functions.
- The MySQL documentation (as recently as 5.0) discusses precision math functions.
- Most significantly, though, it seems that MySQL now offers a library of geo-spatial (GIS) functions which might make it possible for you to go well beyond the Pythagorean Theorem in addressing your problem. The boundaries of each ZIP Code are, of course, a closed polygon, and what you are really looking for here is to determine containment of a chosen point within this and/or adjacent polygons. MySQL 5.0, for instance, appears to have considerable direct support for this. You do have to purchase these data sets.