0
CREATE TABLE `sample` (
  `number` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


mysql> select * from sample
+-------------------+
| number            |
+-------------------+
| 1                 |
| 2                 |
| 3.5               |
| 4.5               |
| 0.1               |
+-------------------+

How can I get only the three decimal numbers?

+-------------------+
| number            |
+-------------------+
| 3.5               |
| 4.5               |
| 0.1               |
+-------------------+
zono
  • 8,366
  • 21
  • 75
  • 113

3 Answers3

2

Here's one option with cast:

select * 
from sample
where cast(number as unsigned) <> number
sgeddes
  • 62,311
  • 6
  • 61
  • 83
1

Here is a another way using % opertaor

select *
from Youtable
where `number` % 1 <> 0
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
0

solution:

SELECT * FROM sample where number like '%.%';
Pravash Panigrahi
  • 701
  • 2
  • 7
  • 21