这些结果是如何解释的?我不明白。
例如,最后一个查询不应该返回一个空集,因为没有日期为> 2010的线程吗?为什么它会返回2003年的结果?
mysql> SELECT *
FROM thread
WHERE newsgroup_id = '64654'
AND 'thread_date' < '2010-09-10 21:43:05'
LIMIT 1;空集(0.00秒)
mysql> SELECT *
FROM thread
WHERE newsgroup_id = '64654'
AND 'thread_date' < '2000-09-10 21:43:05'
LIMIT 1;空集(0.00秒)
mysql> SELECT *
FROM thread
WHERE newsgroup_id = '64654'
AND 'thread_date' > '2000-09-10 21:43:05'
LIMIT 1;
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+
| newsgroup_id | thread_id | postcount | hash | thread_date | thread_date_last | thread_title | title_has_valid_charset |
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+
| 64654 | 1 | 0 | O2gvcPRl | 2003-06-06 22:51:24 | 0000-00-00 00:00:00 | Vendo fotodigit 2.1 megapixel | 0 |
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+集合中的1行(0.00秒)
mysql> SELECT *
FROM thread
WHERE newsgroup_id = '64654'
AND 'thread_date' > '2010-09-10 21:43:05'
LIMIT 1;
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+
| newsgroup_id | thread_id | postcount | hash | thread_date | thread_date_last | thread_title | title_has_valid_charset |
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+
| 64654 | 1 | 0 | O2gvcPRl | 2003-06-06 22:51:24 | 0000-00-00 00:00:00 | Vendo fotodigit 2.1 megapixel | 0 |
+--------------+-----------+-----------+----------+---------------------+---------------------+---------------------------------+-------------------------+集合中的1行(0.00秒)
发布于 2011-08-15 02:49:25
您使用了错误的引号类型。MySQL认为您正在比较字符串"thread_date“。下面是它应该是什么样子的:
`thread_date` > '2010-09-10 21:43:05'这样,MySQL就知道您指的是字段thread_date,并将其与表达式右侧的日期进行比较。
发布于 2011-08-15 02:51:46
'thread_date'是一个字符串,而不是该字段的值。
你的意思是:
`thread_date` > '2010-09-10 21:43:05'https://stackoverflow.com/questions/7058901
复制相似问题