먼저 테이블을 생성하겠습니다 -
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)