Queries lesson 7 'between"


#1

when i use SELECT * FROM movies
WHERE name BETWEEN 'A' AND 'J';
The statement filters the result set to only include movies with names that begin with letters "A" up to but not including "J".
Why it is not including J whereas in query of year it is including 2000 year.


#2

It would be the same as including up to 2000, you wouldn't get 2001 so including up to J means you won't get Ja.

It is including any title that is just J. You should test that by adding a movie that has a title like that.


#3

Why it is not like this: BETWEEN 'A%' and 'J%'


#4

@paralacks
Read this for some inspiration
http://stackoverflow.com/questions/9893329/sql-where-criteria-to-find-names-between-a-f
http://stackoverflow.com/questions/5980783/sql-between-clause-with-strings-columns


#5

Thanks @leonhard.wettengmx.n for the response. I have the question. The linked threads are a little complex for my understanding. Would you mind simply explaining why BETWEEN 'A%' and 'J%' wouldn't work?

I see " where name like 'A%' or name like 'J%' " referenced in another thread. Why do you have to use a LIKE statement with the wildcard?

Thanks for the help!


#6

The answer from lesson 7 between are the letters "A" and "J" with the large size.
If we put the letter with the small size as "a" and "j" will give error


#7

just type

SELECT * FROM movies
WHERE year BETWEEN 1990 AND 2000
AND genre = 'comedy';