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 trialJean-Pierre Vertil
8,371 PointsNot sure what I'm doing wrong. Any advice? Thanks!
SELECT Name FROM Fruit WHERE Name BETWEEN "A" AND "K" UNION SELECT Name FROM Vegetable WHERE Name BETWEEN "A" AND "K";
2 Answers
Steven Parker
231,248 PointsYou have the right idea, but you used the wrong limits.
Any word starting with "K" will be considered alphabetically greater than just the letter "K". Try:
... Name BETWEEN "A" AND "Kz"
Kerry Collier
Front End Web Development Techdegree Student 16,151 PointsYou'll want to use the Less Than operator for the letters. WHERE Name < "K" for example.
Steven Parker
231,248 PointsSee my answer — the issue is the same whichever type of comparison you use. For example, 'Kiwi' < 'K'
would be false.
Kerry Collier
Front End Web Development Techdegree Student 16,151 PointsI couldn't remember which letter it was actually looking for, but I used the Less than Operator like they used in the examples prior to that as I figured it was what they were looking for.
Jason Anello
Courses Plus Student 94,610 PointsThat was how I solved it too.
I used Name < "L"
since we didn't want anything beginning with 'L' or greater if I remember right.
Jean-Pierre Vertil
8,371 PointsJean-Pierre Vertil
8,371 PointsThank you Steven!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsI don't think this can be solved accurately with BETWEEN because it's inclusive.
It might be fine with fruits and vegetables but I think it's problematic in the general case of any string or even if these were last names instead of fruits and vegetables.
Your WHERE clause won't match the string 'Kza' for example.
Others have given the solution
BETWEEN "A" AND "L"
but that will incorrectly include the string "L"