首页 » Mysql函数

数学函数

ROUND()函数执行四舍五入的运算:

mysql> select round(3.15926,2);
+------------------+
| round(3.15926,2) |
+------------------+
|             3.16 |
+------------------+
1 row in set (0.00 sec)

TRUNCATE()函数直接截断浮点数(按保留的小数位数截断):

mysql> select truncate(3.15926,2);     
+---------------------+
| truncate(3.15926,2) |
+---------------------+
|                3.15 |
+---------------------+
1 row in set (0.00 sec)

日期与时间函数

DATE()函数获取日期值:

mysql> select order_time, date(order_time) from orders where order_id = 1234;
+---------------------+------------------+
| order_time          | date(order_time) |
+---------------------+------------------+
| 2012-02-15 16:50:27 | 2012-02-15       |
+---------------------+------------------+
1 row in set (0.00 sec)

字符串函数

CONCAT()函数合并字符串:

mysql> select concat(first_name, ' ', last_name) as full_name from address where addr_id = 1234;    
+-------------+
| full_name   |
+-------------+
| Leon Laptos |
+-------------+
1 row in set (0.00 sec)

分享

0