回答編集履歴
1
SQL追記
answer
CHANGED
@@ -8,4 +8,40 @@
|
|
8
8
|
+-------------------------------+
|
9
9
|
1 row in set (0.00 sec)
|
10
10
|
|
11
|
-
とかダメですか?
|
11
|
+
とかダメですか?
|
12
|
+
|
13
|
+
```SQL
|
14
|
+
CREATE TABLE `str_to_date` (
|
15
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
16
|
+
`date_str` char(6) DEFAULT NULL,
|
17
|
+
PRIMARY KEY (`id`)
|
18
|
+
);
|
19
|
+
```
|
20
|
+
|
21
|
+
```SQL
|
22
|
+
SELECT * FROM test.str_to_date;
|
23
|
+
```
|
24
|
+
|
25
|
+
```
|
26
|
+
mysql> select * from test.str_to_date;
|
27
|
+
+----+----------+
|
28
|
+
| id | date_str |
|
29
|
+
+----+----------+
|
30
|
+
| 1 | 201810 |
|
31
|
+
| 2 | 201809 |
|
32
|
+
| 3 | 201812 |
|
33
|
+
| 4 | 201712 |
|
34
|
+
| 5 | 201908 |
|
35
|
+
+----+----------+
|
36
|
+
```
|
37
|
+
|
38
|
+
```
|
39
|
+
mysql> SELECT * FROM test.str_to_date where str_to_date(date_str, '%Y%m') > str_to_date('201809', '%Y%m');
|
40
|
+
+----+----------+
|
41
|
+
| id | date_str |
|
42
|
+
+----+----------+
|
43
|
+
| 1 | 201810 |
|
44
|
+
| 3 | 201812 |
|
45
|
+
| 5 | 201908 |
|
46
|
+
+----+----------+
|
47
|
+
```
|