Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.