Possible Duplicate:
Difference in SQL Between operator and “>=” & “<=” operator
I see that my developer is using this construction for selecting data of selected date interval:
SELECT ... WHERE `date` >= '2011-11-28' AND `date` <= '2011-12-04'
I recommend him to use BETWEEN operator like this one:
SELECT ... WHERE date BETWEEN '2011-11-28' AND '2011-12-04'
Which solution is better and what are arguments for it?
AFAIK, there is no difference between this approaches in terms of execution efficiency. But
BETWEEN X AND Yseems to be more readable and nice, so I’d like to use this construction instead ofdate >= '2011-11-28' AND date <= '2011-12-04'too.BUT: If for example you are write simple datetime filter in your app, you need an opportunity to pick only first or only second date – this is the case where
date >= '2011-11-28' AND date <= '2011-12-04'should be used (we can omit date >= ‘2011-11-28’ or omit date <= ‘2011-12-04’ in our query builder without problems).