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

MANOJ MANN
MANOJ MANN
1,793 Points

How to perform Union between 2 tables

here are two tables Fruit and Vegetable table. The Fruit table has a Fruit ID and a Name column and the Vegetable table has a Vegetable ID and Name column.

Create a list of all fruits and vegetables starting with the letters A through K .

Steven Parker
Steven Parker
231,269 Points

This sounds like one of the course challenges, but it doesn't look like you've written anything for it yet.

At least please give it your best "good faith" try, and then post your code if you're still having trouble with it.

2 Answers

MANOJ MANN
MANOJ MANN
1,793 Points

I have tried and my code is

Select Name from Fruit where Name not like '[L-Z]%' UNION Select Name from Vegetable where Name Not like '[L-Z]%'

this code works at my local SQL database. However, it is still displaying error

Steven Parker
Steven Parker
231,269 Points

Databases often have different features, and I don't think that SQLite (as used in the course) implements character classes (like '[L-Z]') as a matching wilcard method like some other databases do.

But what you can do is take advantage of how the comparison operator works with strings. For example, "name < 'L'" would also be a way to filter out words that being with L through Z.