Why doesn't ' WHERE LAST_NAME <= 'N' ' work?
I was trying out different methods answer the question asked in the video and tried the code below but the last result only goes to 'Murray'.
SELECT * FROM STUDENTS WHERE LAST_NAME <= 'N' ORDER BY LAST_NAME ASC
I was wondering why it doesn't include last names starting with N, even though it's an equal to or less than operator.
Steven Parker203,731 Points
Anything with other letters following "N" would be considered to come later in alphabetic sequence, so only the single letter "N" would meet this condition.
You'd be likely to get the behavior you want with something like
<= "Nzzzzz", but an even safer test would be
Stephen ColeCourses Plus Student 10,607 Points
Did you mean:
SELECT LAST_NAME, FIRST_NAME FROM STUDENTS WHERE LAST_NAME <= 'M' ORDER BY LAST_NAME ASC;
This does solve the problem of printing a list of names A-M:
WHERE LAST_NAME <= 'N'
...as words (with multiple letters) that start with the letter M are before the single letter N.
However, if you use this...
WHERE LAST_NAME <= 'M'
...there is no way to account for words that start with the letter M. It's a single value. (There's no way to use a wildcard character.)