What's the difference between
I have my first request
select count(*)
from `order`
where marketer_id = 75 and
HandleStatus != -1 and
(Created_at BETWEEN '2017-05-01' AND '2017-05-31')
and the result is 1050
I also have a second request:
select count(*)
from `order`
where marketer_id = 75 and
HandleStatus != -1 and
(Month(Created_at) =5 and Year(Created_at) = 2017)
and the result is 1111
I think 2 queries have the same meaning, but it returns 2 different results. Column information "Created_at": COLUMN_NAME Created_at, COLUMN_TYPE timestamp, IS_NULLABLE NO, COLUMN_KEY, COLUMN_DEFAULT CURRENT_TIMESTAMP
Please help, what's the difference between the two queries?
+3
source to share
3 answers
Between only runs before '2017-05-30 23:59:59' and after 2017-05-01 00:00:00. It does not have to count the 31st full day.
If you want the first query to return the same data as the second query, you can use this like
select count(*)
from `order`
where marketer_id = 75 and
HandleStatus != -1 and
(Created_at >= '2017-05-01' AND Created_at < '2017-06-01')
0
source to share