How to round down to nearest integer in MySQL?

前端 未结 7 1189
自闭症患者
自闭症患者 2020-12-24 04:26

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

Example: 12345.7344 rounds to 12345

mysql\'s round() function rounds up.

7条回答
  •  独厮守ぢ
    2020-12-24 05:07

    Try this,

    SELECT SUBSTR(12345.7344,1,LOCATE('.', 12345.7344) - 1)
    

    or

    SELECT FLOOR(12345.7344)
    

    SQLFiddle Demo

提交回复
热议问题