Unanswered: selecting records from a range of values
Hi to all,
I wanted to retrieve records that are within the range of 2 letters.
I want to retrieve the student's surnames that starts with A and ends with C. I tried to run a query that uses the BETWEEN keyword in my WHERE clause, but the results turned out to return only records from A to B only.
The same output goes if you use the field>='A%' and field<='B%' which is the same as using the BETWEEN keyword on your query.
What I did is just use the LEFT function of MySQL and compared it to the start letter and end letter, which gave me the results I wanted.
My question is that if there is another better or efficient way to do this? What if some other RDBMS does not support the LEFT function?
I want to ask also why the BETWEEN keyword does not return records that start with the letter C in my query, but does retrieve records that start with letter A. Which I have specified in my BETWEEN query such as this: