have 절을 사용할 수 있습니다. 먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable -> ( -> AdmissionDate varchar(100) -> ); Query OK, 0 rows affected (0.55 sec)
삽입 명령을 사용하여 테이블에 일부 레코드 삽입 -
mysql> insert into DemoTable values('10/12/2017'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('01/11/2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('31/01/2019'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('09/06/2019'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('19/04/2019'); Query OK, 1 row affected (0.23 sec)
select 문을 사용하여 테이블의 모든 레코드 표시 -
mysql> select *from DemoTable;
출력
+---------------+ | AdmissionDate | +---------------+ | 10/12/2017 | | 01/11/2018 | | 31/01/2019 | | 09/06/2019 | | 19/04/2019 | +---------------+ 5 rows in set (0.00 sec)
다음은 STR_TO_DATE 열 -
에 대한 쿼리입니다.mysql> select STR_TO_DATE(AdmissionDate, '%d/%m/%Y') as newDate from DemoTable -> having newDate >= '2019-01-01';
출력
+------------+ | newDate | +------------+ | 2019-01-31 | | 2019-06-09 | | 2019-04-19 | +------------+ 3 rows in set (0.00 sec)