Here is the below query
SELECT * FROM music_history WHERE date1 BETWEEN 2017-06-24 AND 2017-06-01
when is run this query in phpmyadmin
it says MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0011 sec )
even though i have date available from to that range in database.
Here is the database image
In a BETWEEN
query, the two operands are ordered. So, this should do what you want:
WHERE date1 BETWEEN '2017-06-01' AND '2017-06-24'
I assume the lack of single quotes was just a typo.
I would encourage you to write the query using binary comparisons, in this fashion:
WHERE date1 >= '2017-06-01' AND date1 < '2017-06-25'
This works even when date1
has a time component.
You might find this blog interesting. Although it is about SQL Server, it really applies to any database:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments