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. 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.
This example returns 0 results:
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.
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';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.