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 trialStephen Robinson
7,461 PointsWhy is my question being marked wrong when it is right?
The original question was: There are two tables Fruit and Vegetable table. The Fruit table has a FruitID and a Name column and the Vegetable table has a VegetableID and Name column.
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.
My response was: Select Name from Fruit Where Name LIKE '[A-K]%' UNION Select Name From Vegetable where Name LIKE '[A-K]%'
I verified the results by bringing it into MS SQL Server
2 Answers
Steven Parker
231,275 PointsThe character class syntax ("[A-K]") you are using in SQL Server is not a feature of SQLite. So you won't be able to use it (or the LIKE operator) for the challenge.
But you can take advantage of the fact that inequality comparisons on strings test dictionary order.
Stephen Robinson
7,461 PointsAhhh that worked! Thank you.
Stephen Robinson
7,461 PointsStephen Robinson
7,461 PointsHey Steven,
I tried using inequality operators like you suggested but I am still getting the same error. I tested my query in MS SQL Server and verified that my syntax is correct and am returning similar results.
Select Name from Fruit Where Name <= 'K%' and Name >= 'A%' UNION
Select Name From Vegetable where Name <= 'K%' and Name >= 'A%'
Steven Parker
231,275 PointsSteven Parker
231,275 PointsNow that one I would not expect to work in SQL Server either, since the wildcard ("%") is only useful in a LIKE.
But
Name < 'L'
would cover anything that begins with A through K.