Search code examples
mysqlsqlrounding

How to round down to nearest integer in MySQL?


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.


Solution

  • Use FLOOR:

    SELECT FLOOR(your_field) FROM your_table