How to round down to nearest integer in MySQL?

d-_-b picture d-_-b · Sep 11, 2012 · Viewed 153.8k times · Source

How would I round down to the nearest integer in MySQL?

Example: 12345.7344 rounds to 12345

mysql's round() function rounds up.

I don't know how long the values nor the decimal places will be, could be 10 digits with 4 decimal places, could be 2 digits with 7 decimal places.

Answer

Jocelyn picture Jocelyn · Sep 11, 2012

Use FLOOR:

SELECT FLOOR(your_field) FROM your_table