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 trialAdriano De Oliveira
5,653 PointsHello ! 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.
Adriano De Oliveira
5,653 PointsAdriano De Oliveira
5,653 PointsSelect name from fruit union select name from vegetable; (missing intersection)
3 Answers
Steven Parker
231,271 PointsHere'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
andFROM
clauses) - you want a complete list, so your set operation would be
UNION
instead ofINTERSECT
- for task 1 no filtering (
WHERE
) or sorting (ORDER BY
) is needed
And remember to delete your duplicate question.
Adriano De Oliveira
5,653 PointsHello 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
231,271 PointsMy hints were based on the requirements for task 1. Which task are you stuck on?
Adriano De Oliveira
5,653 PointsHi, 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
231,271 PointsThey 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.
nfs
35,526 PointsUmm.. looks like I did stumble on the duplicate question.
Dave AB
2,617 PointsSo you are intersecting names existing on both tables .
SELECT name FROM fruit INTERSECT SELECT name FROM vegetable ORDER BY name;
Lucian Rotaru
4,983 PointsSELECT Name FROM FRUIT INTERSECT SELECT Name FROM Vegetable ORDER BY Name ASC;
Steven Parker
231,271 PointsFYI: Explicit answers without any explanation are strongly discouraged by Treehouse and may be redacted by moderators.
Adriano De Oliveira
5,653 PointsAdriano De Oliveira
5,653 PointsSelect 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