FLOOR() in MySQL — How It Works

What the MySQL FLOOR() function does, with an example.

Published October 21, 2026

FLOOR(x) returns the largest integer less than or equal to x, rounding down toward negative infinity.

How it works

For negative numbers it goes further from zero.

Try it in MySQL

SELECT FLOOR(3.9)
3
SELECT FLOOR(-3.1)
-4
SELECT FLOOR(price / 10) * 10 FROM products LIMIT 1
bucket

Practical examples

Example 1

SELECT FLOOR(3.9);
-- 3

Example 2

SELECT FLOOR(-3.1);
-- -4

Example 3

SELECT FLOOR(price / 10) * 10 FROM products LIMIT 1;
-- bucket

Use it in a real query

SELECT id, FLOOR(3.9) AS result
FROM your_table
LIMIT 10;

Common mistakes

  • Expecting -3.1 to become -3.
  • Using FLOOR for rounding to decimals.
  • Integer division confusion (use DIV).

Key takeaways

  • FLOOR() in one line: FLOOR(x) returns the largest integer less than or equal to x, rounding down toward negative infinity.
  • Try queries in a test database first.
  • Check NULL handling and data types.

FAQ

FLOOR vs TRUNCATE?

FLOOR(-3.1) = -4; TRUNCATE(-3.1,0) = -3.

Does FLOOR() work in other databases?

Most have an equivalent, but names and syntax vary between MySQL, PostgreSQL, SQL Server and SQLite.

More SQL articles