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

jessicakelly
jessicakelly
5,901 Points

Need help with UNION in sql! - challenge task 1 of 6

Querying Relational Databases: Challenge Task 1 of 6

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 distinct result set of fruit and vegetable names.

SELECT Name, FruitID FROM Fruit
UNION
SELECT Name, VegetableID FROM Vegetable;

This is what I have but it does not seem to be working...

Can anyone help?

1 Answer

Steven Parker
Steven Parker
231,128 Points

The instructiosn say, "Create a distinct result set of fruit and vegetable names." That sounds like they only want to see the name column. But your query is also returning the ID column.

jessicakelly
jessicakelly
5,901 Points

Oh my god, I can't believe I missed that! ? Thank you so much! ?