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 , 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
Steven Parker
231,248 Points

You 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
Diana Ci
18,672 Points

The Correct answer is: SELECT Name FROM Vegetable EXCEPT SELECT Name FROM Fruit ORDER BY Name;

Steven Parker
Steven Parker
231,248 Points

:warning: FYI: According to a moderator, explicit answers without any explanation are strongly discouraged by Treehouse.

You have to query the vegetables first ... like SELECT Name FROM Vegetables ... regards, Jan.

Sean M
Sean M
7,344 Points

SELECT 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.

help 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
Steven Parker
231,248 Points

I'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!

@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
Steven Parker
231,248 Points

I get it, and my hint is asking you why do you have this clause: WHERE Name = "Vegetable".

where 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
Steven Parker
231,248 Points

Why do you have WHERE clause at all?

I 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 (:

wic code worked for you

SELECT Name FROM Vegetable INTERSECT SELECT Name FROM Fruit ORDER BY Name;