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 trialvictorvillaplana
11,582 PointsProblem with task 2 of 6
I don't know what's the problem with my query:
SELECT Name FROM Fruit WHERE Name BETWEEN "A" AND "K" UNION SELECT Name FROM Vegetable WHERE Name BETWEEN "A" AND "K" ORDER BY Name;
Could you help me? Thanks
2 Answers
Robert Stefanic
35,170 PointsThere's a small syntax problem here, but you're on the right track.
You want to select Fruits and Vegetables where the Name is >= a letter and less than or equal to another letter; however, when I tried doing "Name <= 'K'
, it gave me an error. If I did name < 'L'
, then everything worked just fine. Even though the former should work, it didn't (for me at least). So the part that checks your input must be very specific.
SELECT Name
FROM Fruit
WHERE Name >= 'A' AND Name < 'L'
UNION
SELECT Name
FROM Vegetable
WHERE Name >= 'A' AND Name < 'L'
ORDER BY Name
victorvillaplana
11,582 PointsThanks Robert!
I tried your query and it worked.