我有一個帶有TIME列的數據庫,並且想要將該時間的舍入版本與另一個時間列表。我如何將MySQL TIME四捨五入到最近的小時(不是日期時間/時間戳)
Example:
[email protected] (mytest) desc ss;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| t | time | YES | | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.01 sec)
[email protected] (mytest) desc tt;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| s | time | YES | | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.00 sec)
[email protected] (mytest) select * from ss;
+----------+
| t |
+----------+
| 16:00:00 |
+----------+
1 row in set (0.00 sec)
[email protected] (mytest) select * from tt;
+----------+
| s |
+----------+
| 15:45:00 |
| 16:00:00 |
| 19:30:00 |
| 17:45:00 |
| 18:00:00 |
| 19:30:00 |
+----------+
需要一個查詢加盟SS和TT圓潤的地方= tt.s ss.t
您沒有使用UNIT_TIMESTAMP功能的原因是什麼? – Selah 2015-04-28 15:37:18