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 trialR.P. Arts
22,284 PointsQuerying Relational Databases , Challenge Task 6 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 an alphabetical list of vegetables that are NOT considered a fruit.
Type in your command below.
SELECT FruitID, Name FROM Fruit
EXCEPT
SELECT VegetableID, Name FROM Vegetable
WHERE NAME = 'Vegetable';
ORDER BY NAME
What am I doing wrong ?
9 Answers
Steven Parker
231,248 PointsYou might have your terms reversed.
The task asks for a "list of vegetables that are NOT considered a fruit", but it looks like you're preparing a list of fruits that are not considered a vegetable instead.
And are you sure you want to only consider vegetables that have a name of "Vegetable"?
Also, it might only want names (and not ID's).
To facilitate the most accurate answers, always provide a link the course page you are working with.
Diana Ci
18,672 PointsThe Correct answer is: SELECT Name FROM Vegetable EXCEPT SELECT Name FROM Fruit ORDER BY Name;
Steven Parker
231,248 PointsFYI: According to a moderator, explicit answers without any explanation are strongly discouraged by Treehouse.
Jan Oberreiter
78,020 PointsYou have to query the vegetables first ... like SELECT Name FROM Vegetables ... regards, Jan.
Sean M
7,344 PointsSELECT Name FROM Vegetable EXCEPT SELECT Name FROM Fruit ORDER BY Name;
Selecting names from the vegetable table that are not found in the names from the fruit table.
order by name will list the results alphabetically.
Calvin . T Rupango
6,083 Pointshelp i cant seem to be able to get it through... This is my solution but i seem to be having a hard time what will be the problem
SELECT Name FROM Fruit EXCEPT SELECT Name FROM Vegetable WHERE Name ="Vegetable" ORDER BY Name;
Steven Parker
231,248 PointsI'll ask you the same thing I asked R.P.: Are you sure you want to only consider vegetables that have a name of "Vegetable"?
Hint: there may not be any with that name!
Calvin . T Rupango
6,083 Points@Steven Parker it seems like you are not getting my qn clearly and you seem to make more hard to me... my qn is like this
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 fruits that are NOT considered a vegetable.
and This is my solution which is not running..
SELECT Name FROM Fruit EXCEPT SELECT Name FROM Vegetable WHERE Name ="Vegetable" ORDER BY Name; So i dont know where am getting it all wrong please help.
Steven Parker
231,248 PointsI get it, and my hint is asking you why do you have this clause: WHERE Name = "Vegetable"
.
Calvin . T Rupango
6,083 Pointswhere name = "Fruit"
is suppose to bring back results which are associated with the fruit but still gives me back this Bummer error of .....
Bummer! Your EXCEPT queries didn't bring back fruits that aren't considered a vegetable.
which is actually making me more confused. @Steven Parker please help me out am kinda stuck.
Steven Parker
231,248 PointsWhy do you have WHERE
clause at all?
Calvin . T Rupango
6,083 PointsI now get it and thank you it worked cause the query from start have managed to distinct the two tables from the select names Thank you bro (:
Stewart Mandla Kohlisa
11,737 Pointswic code worked for you
Millicent Ogutu
12,240 PointsSELECT Name FROM Vegetable INTERSECT SELECT Name FROM Fruit ORDER BY Name;