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

Alex Childs
Alex Childs
1,747 Points

How to query based on results that don't start with a particular alphabetical value?

Require assistance in this alphabetical query

2 Answers

Steven Parker
Steven Parker
231,140 Points

Your question is a bit unclear, and you didn't provide a link to a video or challenge. But I'll try a few guesses:

  • if you need to sort your results, you can use an "ORDER BY ..." clause at the end of your query
  • if you need to return a particular range, you can use "WHERE somecolumn BETWEEN value1 AND value2"

If neither of those are what you're looking for, try posting a link to the course video or challenge you are working on. And if a challenge, give it your best shot and also post your code.

Alex Childs
Alex Childs
1,747 Points

Hi Steven. I was referring to the following task...

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.

...in the following link: https://teamtreehouse.com/library/querying-relational-databases/set-operations/set-operations

However, I have since been able to determine the solution with the following code: SELECT Name FROM Fruit WHERE Name < "L" UNION SELECT Name FROM Vegetable WHERE Name <"L" GROUP BY NAME;

Appreciate the quick response