2016-09-25 29 views
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    | 
+-------------------+ 

我怎樣才能得到三個十進制數?MySQL:我怎樣才能從雙類型列獲得十進制值?

+-------------------+ 
| number   | 
+-------------------+ 
| 3.5    | 
| 4.5    | 
| 0.1    | 
+-------------------+ 
+2

用簡單的算術 – Strawberry

+1

http://stackoverflow.com/questions/1860542/what-would-be-a-reliable-way-to-get-fractional-value-from-a-號碼 –

+0

感謝您的意見 – zono

回答

1

這裏有一個選項與cast

select * 
from sample 
where cast(number as unsigned) <> number 
+0

或'樓(號碼)<>號碼' –

+0

它的工作。非常感謝! – zono

+0

地板(數字)也可以工作 – zono

1

下面是使用% opertaor

select * 
from Youtable 
where `number` % 1 <> 0 
一另一種方式
+0

它工作。謝謝! – zono