Last Updated: February 25, 2016
·
516
· geetotes

The proper way to select using a Float column in MySQL

When doing some geocoding of addresses with the helpful Ruby Geocoder gem, I was having some issues trying to select latitudes and longitudes (which are stores as floats) from the DB.

Turns out that this:

SELECT * FROM foo WHERE latitude = -73.555

Is wrong. The proper way to select is:

SELECT * FROM foo WHERE latitude LIKE -73.555

Why this is? I don't know and I don't want to find out. Migrating this DB to Mongo soon....