Search code examples
mysqlfloor

mysql find rows with fractional part of number


Using the MySQL command prompt, I want to SELECT all rows conataining a specific fractional part of number.

I have a field of type FLOAT called priority & I want to find all rows where the priority is X.2 where X can be any whole number.

Is there a way to use the MOD or FLOOR function to extract the ".2" in a query?

I've tried:

SELECT * from table
WHERE priority-FLOOR(priority) = .2 *(note the decimal point before the 2)*

but it returns empty set when I know there are at least 100 rows containing a priority of X.2

Thanks


Solution

  • What about using the LIKE clause in MySQL?

    SELECT * FROM table WHERE priority LIKE %.2%