如何在MySQL中舍入到最接近的整数?
要舍入到最接近的整数,请使用FLOOR()MySQL中的函数。语法如下-
SELECT FLOOR(yourColumnName) from yourTableName;
让我们首先创建一个表-
mysql> create table FloorDemo -> ( -> Price float -> );
将记录插入价格列。插入记录的查询如下-
mysql> insert into FloorDemo values(5.75); mysql> insert into FloorDemo values(5.23); mysql> insert into FloorDemo values(5.50);
在select语句的帮助下显示表中存在的记录。查询如下-
mysql> select *from FloorDemo;
这是输出-
+-------+ | Price | +-------+ | 5.75 | | 5.23 | | 5.5 | +-------+ 3 rows in set (0.00 sec)
我们有3条记录,我们想要最接近的整数。为此,请使用FLOOR()我们上面讨论的功能。
查询如下,implmenetsFLOOR()方法-
mysql> SELECT FLOOR(Price) from FloorDemo;
这是输出-
+--------------+ | FLOOR(Price) | +--------------+ | 5 | | 5 | | 5 | +--------------+ 3 rows in set (0.03 sec)
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便