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 trialGurdeep singh
1,522 PointsCAN WE USE JOINS IN SUBQUERY?
I Have a task to Generate a report that lists the book titles from both locations and count the total number of books with the same title.
Can we use union in subqureries SELECT * FROM books_north LEFT OUTER JOIN (LEFT OUTER JOIN loans_north ON books_north.id = loans_north.book_id UNION ALL SELECT * FROM books_south LEFT OUTER JOIN loans_south ON books_south.id = loans_south.book_id) AS t;
1 Answer
Steven Parker
231,271 PointsTechnically, a subquery is used in a WHERE clause and a derived table is used in a FROM clause. But sure, you can use UNIONs and JOINs in either of them.
However, if all you're interested in are the book titles, you can simply this query a good bit by not joining the "loans" table. And it sounds like you might need the COUNT function in there.
Gurdeep singh
1,522 PointsGurdeep singh
1,522 PointsYes I need a count thank you I am really stuck on this and also on this topic