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 trialWen Yan Cheong
1,482 Pointsmy query is not giving the correct results
for this question
-- Create a list of unique books. -- Books that are in the north or south location, but not in both locations.
i did this:
SELECT books_north.title FROM books_north EXCEPT SELECT books_south.title FROM books_south UNION ALL SELECT books_south.title FROM books_south EXCEPT SELECT books_north.title FROM books_north
but i am only getting 'Congo Jurassic Park Sphere"
I should be getting " Armada Ready Player One The Martian Congo Jurassic Park Sphere""
i do get 'Armada Ready Player One The Martian' correctly with 'SELECT books_north.title FROM books_north EXCEPT SELECT books_south.title FROM books_south' but somehow when i use UNION ALL i am only getting results for the 2nd query instead of joining them
1 Answer
Steven Parker
231,265 PointsThese operations are occurring in sequence, but your intention is perform both EXECPTs before the UNION.
One way you can enforce that order is by using a subquery:
SELECT books_north.title FROM books_north EXCEPT SELECT books_south.title FROM books_south
UNION ALL
SELECT * FROM
( SELECT books_south.title FROM books_south EXCEPT SELECT books_north.title FROM books_north )