[英]Greater than (>) not working in mysql query
I'm trying to run a query on my WordPress database to get a list of all posts and some other data from a certain month. 我正在尝试在WordPress数据库上运行查询,以获取特定月份的所有帖子和其他一些数据的列表。 I'm running into an issue with
post_date
, where looking for posts before a certain date works fine, but looking for posts after a certain date returns 0 results. 我遇到了
post_date
的问题,其中在特定日期之前查找帖子效果很好,但是在特定日期之后查找帖子会返回0结果。
This example returns 0 results: 本示例返回0个结果:
SELECT * FROM `wp_posts` WHERE `post_date` > '2014-01-01 00:00:00';
However this returns a ton of results: 但是,这将返回大量结果:
SELECT * FROM `wp_posts` WHERE `post_date` < '2014-01-01 00:00:00';
There are posts published after 2014-01-01, so that's not the problem. 2014年1月1日之后发布了帖子,所以这不是问题。
Any ideas? 有任何想法吗?
在存在日期列的表中检查您的列数据类型
如果您要评估的只是日期,请尝试将该字段转换为日期:
SELECT * FROM wp_posts WHERE CAST(post_date AS DATE) > '2014-01-01'
Try this i think it will be useful 试试这个,我认为这将是有用的
SELECT * FROM wp_posts
WHERE post_date
'< 2014-01-01 00:00:00'; SELECT * FROM
wp_posts
WHERE post_date
'<2014-01-01 00:00:00';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.