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 Querying Relational Databases Set Operations Set Operations

Hey for challenge 1 of 6. Create a distinct result. I'm getting an error "you're missing UNION keyword"

I'm getting an error "you're missing UNION keyword"

Here is my code - SELECT Name FROM FruitID and VegetableID WHERE type = "Name";

2 Answers

Hi Sherelle,

This question is a little tricky. The question does not specify UNION but you will need to insert a UNION here. What you are looking to do is create one result set from two different tables.

Make sure you have a complete query for both of the Fruit table and the Vegetable table. You will also need to specify a range of results to look for. Since fruits begin with a letter, we will want a return of the fruits starting between the letters 'A' and 'C' or 'A' and 'Z' or any other range you prefer.

So let's break this down. Start with the first table and return the name column like this:

SELECT Name FROM Fruit;

Then write a command for a union to take place to bring the results of the tables together:

UNION 

And finally write the query for the vegetable table the same way. This time though, include a where clause that specifies the range:

SELECT Name FROM Vegetable WHERE Name BETWEEN 'A' AND 'Z';

You can alternatively place the WHERE clause on the first query.

Your finished code should look something like this:

SELECT Name 
FROM Fruit;
UNION 
SELECT Name 
FROM Vegetable 
WHERE Name BETWEEN 'A' AND 'Z';

Cheers!

Thank you!