Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases SQL Basics Finding the Data You Want Review & Practice with SQL Playgrounds

Im a little bit confused about the difference between these two options in the quiz, help!!

I accidentally got the answer right but I dont know how to explain it myself. I don't know the difference between these 2 queries:

Quiz Question: Imagine you wanted to retrieve all appointments in for the upcoming week. Monday is 7th Oct 2019, and Friday is 11th Oct 2019. Which queries is the correct one to use?

A. SELECT * FROM appointments WHERE day > "2019-10-07" AND day < "2019-10-11";

B. SELECT * FROM appointments WHERE day BETWEEN "2019-10-07" AND "2019-10-11";

The correct answer is B. Do the operator such as greater than and smaller than only apply to objects that are not strings? Or is it because I have to used >= and <= if I want to make the answer A correct? I think I miss that one.

1 Answer

Or is it because I have to used >= and <= if I want to make the answer A correct?

Yes because it's asking for all five days of the week, including the two dates specified, and the keyword BETWEEN is inclusive while the comparison operators < and > are not.