Michael Price
Michael Price

Reputation: 52

Mysql Changing My Float Values

I have a database that stores lat and long coords, along with other fields. The lat and long are set to float 10,8.

When running the following command ...

INSERT IGNORE INTO records(unique_id, city, st,zip,lat,lon) VALUES 
( '80936EN476', 'West Jordan', 'UT', '84088-5205', '40.59660', '-111.963' )

The insert is completed with no messages, but when the record is retrieved, the "lon" field has been set to -100.000000.

When I try to edit the value in phpMyAdmin, I get the following error.

Warning: #1264 Out of range value for column 'lon' at row 1

Upvotes: 1

Views: 717

Answers (3)

Rick James
Rick James

Reputation: 142296

Do not use (m,n) on FLOAT or DOUBLE. It leads to an extra rounding. And, in your case, it leads to truncation in the upper digits.

Upvotes: 1

Michael Price
Michael Price

Reputation: 52

Ok, the issue turned out to be the float values. I changed it to 10,6 and that resolved the issue!

Upvotes: 0

Jonathan Thérien
Jonathan Thérien

Reputation: 293

You need to put more digits in front.

10,8 means 2 digits before decimal and 8 decimal digits. try putting something like 12,8

Upvotes: 2

Related Questions