我有这个简单的 Mysql 查询
select *
from reportings
where findcampaign = 1 and
is_click = 1 and
created_at BETWEEN date(2016-11-01) AND date(2016-12-31)
这应该返回 findcampaign = 1 且 is_click is = 1 的所有行,其中created_at 日期在 2016 年 11 月 1 日到 2016 年 12 月 31 日之间。
正在运行select * from reportings where findcampaign = 1 and is_click = 1
给我 12 行
图像显示这些报告均在这些日期之间,因此我应该获得 12 行。即使我的created_at有时间戳值,这是从数据库获取日期和日期之间的正确方法吗?或者我需要在日期中附加时间吗?
最佳答案
你应该为日期加上引号
select *
from reportings
where findcampaign = 1 and
is_click = 1 and
created_at BETWEEN date('2016-11-01') AND date('2016-12-31')
关于mysql - 不返回所有结果之间的 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40973972/