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 trialHannah Tucker McLellan
1,856 PointsWhy doesn't my query work? Name of Fruit and Veg between A - K
I've tried various combinations of something like this:
SELECT Name FROM Fruit UNION SELECT Name FROM Vegetable WHERE Name >= 'A' AND Name <= 'K'
2 Answers
Richard Price
17,787 PointsSo this for conciseness
SELECT name FROM Fruit WHERE name between "A" AND "L"
UNION
SELECT name FROM Vegetable WHERE name between "A" AND "L"
Tristan Magpantay
Full Stack JavaScript Techdegree Student 14,032 Pointsyou can try something like this
SELECT name FROM fruit WHERE(LEFT(name,1) >= "a" AND LEFT(name,1) <= "k")
UNION
SELECT name FROM vegetable WHERE (LEFT(name,1) >= "a" AND LEFT(name,1) <= "k")
Hannah Tucker McLellan
1,856 PointsThis made me realise why my query was obviously not working. Thanks!!
Richard Price
17,787 PointsRichard Price
17,787 PointsTry using the BETWEEN operator, and remember this will not include the right range so go to 'L'