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

Hello ! I would like some help in this challange. thanks

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 an alphabetical list of produce that is considered both a fruit and a vegetable.

Select Fruit ID and Vegetable ID where name fruit column= INTERSECT vegetable name, name order by name asc;

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

Select name from fruit union select name from vegetable; (missing intersection)

3 Answers

Steven Parker
Steven Parker
231,248 Points

Here's a few hints:

  • you want to return the Name of the items, not their ID's
  • your set operator should go between full queries (with SELECT and FROM clauses)
  • you want a complete list, so your set operation would be UNION instead of INTERSECT
  • for task 1 no filtering (WHERE) or sorting (ORDER BY) is needed

And remember to delete your duplicate question.

Hello Steven ! I receive a bummer message missing intersect!!! select name from fruit union select name from vegetable;

now is ok! > Select name from fruit intersect select name from vegetable order by name asc;

Thanks

Steven Parker
Steven Parker
231,248 Points

My hints were based on the requirements for task 1. Which task are you stuck on?

Hi, Steve! now I have problem with subquery : SELECT Model.ModelID, ModelName, StickerPrice FROM Model LEFT OUTER JOIN Car ON Model.ModelID = Car.ModelID WHERE Car.CarID IN(SELECT Car.CarID FROM Car WHERE StickerPrice >30000);

https://teamtreehouse.com/library/querying-relational-databases/subqueries/subqueries

I would like get some hints from you. Thanks

Steven Parker
Steven Parker
231,248 Points

They only want to see ModelName on that one, and you don't need a JOIN. Just a WHERE clause using IN and a subquery that returns the ModelID.

Don't forget to delete your duplicate question and this one. But it's fine to create a new question for a different challenge.

Umm.. looks like I did stumble on the duplicate question.

Dave AB
Dave AB
2,617 Points

So you are intersecting names existing on both tables .

SELECT name FROM fruit INTERSECT SELECT name FROM vegetable ORDER BY name;

SELECT Name FROM FRUIT INTERSECT SELECT Name FROM Vegetable ORDER BY Name ASC;

Steven Parker
Steven Parker
231,248 Points

:warning: FYI: Explicit answers without any explanation are strongly discouraged by Treehouse and may be redacted by moderators.