Why for last element BETWEEN is inclusive if it's an integer but not inclusive if it's a string?


#1

SELECT * FROM movies
WHERE name BETWEEN 'A' AND 'J';

This statement filters the result set to only include movies with names that begin with letters "A" up to but not including "J".

SELECT * FROM movies WHERE year BETWEEN 1990 AND 2000;

In this statement, the BETWEEN operator is being used to filter the result set to only include movies with years between 1990 up to and including 2000.

This doesn't make sense to me, what's the difference between apart from data types? Why one is exlusive and the other is inclusive?


#2

There is no difference, they are both inclusive. I have put some information about that over in this thread: http://discuss.codecademy.com/t/between-----and----/3164/2?u=albionsrefuge

The beginning of that discussion goes like this:

Did you test a name that was just J? If you did, then it would have been selected.

What won't be selected is everything higher than J, like Ja or Je. This is just like 2000 would be selected but not 2001.

Let me know if that clears things up for you.