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 Set Operations Union All Operations

Sean Flanagan
Sean Flanagan
33,235 Points

Task 2

Hi. I used the EXCEPT operator for this task but I couldn't exclude books that were in both tables.

-- Create a list of unique books. 
-- Books that are in the north or south location, but not in both locations.

SELECT * FROM books_north
  EXCEPT
SELECT * FROM books_south

Am I doing something wrong?

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

Hey Sean,

I suggest rewatching the videos (maybe multiple times?) until the concept starts to click. Posting back-to-back questions on the same topic should be a last resort.

1 Answer

Mustafa Başaran
Mustafa Başaran
28,046 Points

<Query1> EXCEPT <Query2> returns all rows in Query1 that are NOT retrieved in Query2. This is NOT going to return unique books.

On the other hand, <Query1> UNION <Query2> will get ALL rows in Query1 and Query2. Moreover, there will be no DUPLICATE rows.. So, the returned rows will be UNIQUE.