我需要使用回答日期角色的 PHP 脚本来选择 WordPress 的活跃帖子。
这是我尝试过的选择,但没有成功:
select post_title, post_date from wp_posts
where post_date between 2016-01-25 and 2016-01-01
之前,我尝试过这个:
select post_title, post_date from wp_unp_posts where
Date_sub(curdate(), interval '25' day)
或者:
select post_title, post_date from wp_unp_posts where
post_date => curdate() - 25
没有返回结果。
此查询的正确构造是什么?
最佳答案
首先将日期括在单引号中,因为它是字符串类型。并且还交换日期顺序,使第一个日期应小于第二个日期。试试这个:
select post_title, post_date from wp_posts where post_date between '2016-01-01' and '2016-01-25';
关于mysql - 使用php选择mysql中间隔之间的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34997491/