Reputation: 5398
I have following data which clearly showing data available between date used in query
My query
SELECT * FROM dashboard WHERE added BETWEEN "2018-05-08 10:32:32" AND "2018-05-08 10:28:30"
but This query returning empty row set. What going wrong. I have exported this table from production server & imported in development server. added
field is DATETIME
. Please help
Upvotes: 0
Views: 68
Reputation: 35613
The first boundary must be lower than the second.
Try reversing the comparison values. E.g
SELECT * FROM dashboard
WHERE added BETWEEN "2018-05-08 10:28:30"
AND "2018-05-08 10:32:32"
The reason behind this is due to the fact that the first value is compared using >= then the second value compared using <= thus the second value must be greater than the first or nothing is returned.
Upvotes: 3
Reputation: 14389
the clause: BETWEEN "2018-05-08 10:32:32" AND "2018-05-08 10:28:30"
is correctly returning an empty set since from is after until. Did you mean:
BETWEEN "2018-05-08 10:28:30" AND "2018-05-08 10:32:32"
Upvotes: 1