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 trialFilipe Pacheco
Full Stack JavaScript Techdegree Student 21,416 PointsIn a library database there's a books table. There's a title, author, genre and first_published column.
Hey, everyone, I need a help with a code challenge. Here it is:
In a library database there's a books table. There's a title, author, genre and first_published column. The library database is connected to a website displaying 10 books at a time, sorted by the title alphabetically. Write a query to bring back the second page of results.
So I tried many things out and always got the same error. Here is the final query I got to, and I cannot think of anything else.
SELECT title, author, genre, first_published
FROM books
ORDER BY
REPLACE(
REPLACE(
REPLACE(title, 'The ', ''),
'An ', ''),
'A ', '' )
LIMIT 10 OFFSET 10;
From what I understood, I need to get the specific four columns, since there are other columns in this table, then I need to order by title, and then get the second page of results. I really thought this final query could bring that result, but every time I try it, I get this error: Bummer! Your query needs to retrive the earliest 'Science Fiction' book from the books
table.
I checked the table and saw that the earliest Science Fiction is Dune, and if we order by the title alphabetically, it should be in the 7th place, so it shouldn't be in the second page at all. Can anyone help me out with that? What am I seeing wrongly?
Thanks.
4 Answers
Simon Coates
28,694 Pointstry
Select * from books order by title limit 10 offset 10
I think the science fiction message is a mistake. I've complained about it to treehouse about a month back. You might care to email them. Challenge messages are generally good, but there are a couple points in the SQL courses, where the messages you get back are misleading.
Filipe Pacheco
Full Stack JavaScript Techdegree Student 21,416 PointsThanks, Simon Coates I just complicated something very simple. I will definitely write them, this message was very misleading.
HIDAYATULLAH ARGHANDABI
21,058 PointsSelect * from books order by title limit 10 offset 10
Filipe Pacheco
Full Stack JavaScript Techdegree Student 21,416 PointsI thought the code challenge was already linked, here is the link, Ashu Singh :
tree house
981 PointsSELECT * FROM books ORDER BY title ASC LIMIT 10 OFFSET 10;
Ashu Singh
Courses Plus Student 38 PointsAshu Singh
Courses Plus Student 38 Pointscan u please paste the link of code challenge