让我们首先创建一个表-
mysql> create table DemoTable -> ( -> ShippingDate datetime -> );Query OK, 0 rows affected (0.52 sec)
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('2019-01-10 10:04:45');Query OK, 1 row affected (0.18 sec)mysql> insert into DemoTable values('2019-06-11 05:45:00');Query OK, 1 row affected (0.23 sec)mysql> insert into DemoTable values('2019-06-12 07:00:55');Query OK, 1 row affected (0.14 sec)
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+---------------------+ | ShippingDate | +---------------------+ | 2019-01-10 10:04:45 | | 2019-06-11 05:45:00 | | 2019-06-12 07:00:55 | +---------------------+ 3 rows in set (0.00 sec)
这是在MySQL中获取分钟的查询-
mysql> select minute(ShippingDate) as Minutes from DemoTable;
输出结果
+---------+ | Minutes | +---------+ | 4 | | 45 | | 0 | +---------+ 3 rows in set (0.00 sec)