日期条件未在 MySQL 查询中产生任何结果
Date condition not yielding any results in MySQL query
我有一个 table 这样的:
> desc my_tab
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| host | varchar(128) | NO | | | |
| state | varchar(128) | YES | | NULL | |
| cdt | datetime | YES | | NULL | |
| mdt | timestamp | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
有很多行的日期 >= '31-jan-2018 00:00:00'。如果我 运行 select * from my_tab
我确实看到了它们。但是,当我 运行 这个查询时:
select * from my_tab where cdt >= '31-jan-2018 00:00:00'
我没有得到任何结果。
我做错了什么?
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-types.html
Although MySQL tries to interpret values in several formats, date parts must always be given in year-month-day order (for example, '98-09-04'), rather than in the month-day-year or day-month-year orders commonly used elsewhere (for example, '09-04-98', '04-09-98').
我有一个 table 这样的:
> desc my_tab
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| host | varchar(128) | NO | | | |
| state | varchar(128) | YES | | NULL | |
| cdt | datetime | YES | | NULL | |
| mdt | timestamp | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
有很多行的日期 >= '31-jan-2018 00:00:00'。如果我 运行 select * from my_tab
我确实看到了它们。但是,当我 运行 这个查询时:
select * from my_tab where cdt >= '31-jan-2018 00:00:00'
我没有得到任何结果。
我做错了什么?
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-types.html
Although MySQL tries to interpret values in several formats, date parts must always be given in year-month-day order (for example, '98-09-04'), rather than in the month-day-year or day-month-year orders commonly used elsewhere (for example, '09-04-98', '04-09-98').