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

Not 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
Steven Parker
231,140 Points

:point_right: You 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"

Thank you Steven!

I 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"

Steven Parker
Steven Parker
231,140 Points

See my answer — the issue is the same whichever type of comparison you use. For example, 'Kiwi' < 'K' would be false.

Kerry Collier
seal-mask
.a{fill-rule:evenodd;}techdegree
Kerry Collier
Front End Web Development Techdegree Student 16,151 Points

I 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.

That 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.