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 trialdierkpolzin
7,380 PointsCreate a list of all fruits and vegetables starting with the letters A through K . SQL Fails
Create a list of all fruits and vegetables starting with the letters A through K . In other words all fruit and vegetables that don't start with the letter L to Z.
SELECT Name FROM Fruit
WHERE Name NOT LIKE '[L-Z]%'
UNION
SELECT Name FROM Vegetable
WHERE Name NOT LIKE '[L-Z]%'
3 Answers
Andreas Frost Nordstrøm-Hansen
2,443 PointsIt needs to look like this.
SELECT name FROM Fruit
WHERE name BETWEEN 'A' AND 'L'
UNION
SELECT name FROM Vegetable
WHERE Name BETWEEN 'A' AND 'L';
use L because otherwise it wont take K with it
dierkpolzin
7,380 PointsThanks worked great..
Michael Kroon
16,255 PointsThough you can use the BETWEEN keyword, one of the examples that he used during this video set included a less than or greater than operator. I was able to answer the question using this code:
SELECT name FROM fruit
WHERE name < "L"
UNION SELECT name FROM vegetable
WHERE name < "L";
Christopher Phillips
10,061 PointsWhy wouldn't the following also work?
SELECT name FROM fruit
WHERE name <= "K"
UNION SELECT name FROM vegetable
WHERE name <= "K";
Logically, it's still satisfying the requirement. Perhaps the application is not set up to receive that answer.
Erik Snider
2,516 PointsErik Snider
2,516 PointsI'm not on this track so I don't know if this is in context. Have you tried just doing one part of the query at a time? Are the names upper case?