MySQL’s BETWEEN includes all results between two endpoints as well as the endpoints.
If expr is greater than or equal to min and expr is less than or equal
to max, BETWEEN returns 1, otherwise it returns 0. This is equivalent
to the expression (min <= expr AND expr <= max) if all the arguments
are of the same type. REFERENCE- http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between
Is there an function like REALLYBETWEEN which doesn’t include the endpoints, or am I stuck using min < expr AND expr < max?
I think you can just write it yourself as:
Between is:
As for indexes, the first two should use an index correctly and identically to
between, assuming that start and end are constants. I’m not sure if the last version will.If val is a complicated expression, then consider the following:
This should evaluate
valonly once. I think the other forms would evaluate it twice.Or, you could do: