为什么?
在这项计划中,我有:
`date_published` DATETIME NOT NULL,
但现在当我:
mysql> select min(date_published) from articles;
+---------------------+
| min(date_published) |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (5.47 sec)
但当我:
mysql> select * from articles where date_published = '0000-00-00 00:00:00';
ERROR 1525 (HY000): Incorrect DATETIME value: '0000-00-00 00:00:00'
我不明白.我是怎么插进go 的?
如何查找包含此日期的行?
Update个
>>> db.execute("INSERT INTO articles (edition_id, url, date_published, title, weight) VALUES (%s, %s, %s, %s, %s)", (1, "", "0000-00-00 00:00:00", "", 0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
... yadda yadda stack trace
packages/mysql/connector/connection.py", line 784, in _handle_result
raise get_exception(packet)
mysql.connector.errors.DataError: 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'date_published' at row 1
我在MySQL客户端和代码中都try 过.当我测试它时,这两个似乎都不起作用,但该行在表中.
Update 2个
在我的客户端为会话禁用NO_ZERO_DATE
之后,我能够找到导致此问题的行.
它们被插入的日期是'0003-01-26 00:00:00+00:00'
现在,当我查询它时,我找到了它们,但如果0003:
mysql> select date_published from articles where date_published = '0003-01-26 00:00:00+00:00';
+---------------------+
| date_published |
+---------------------+
| 0000-00-00 00:00:00 |
| 0000-00-00 00:00:00 |
| 0000-00-00 00:00:00 |
| 0000-00-00 00:00:00 |
+---------------------+
4 rows in set (5.41 sec)
+00:00
很重要,否则我会得到一套空的.