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

PHP

Filipe Pacheco
seal-mask
.a{fill-rule:evenodd;}techdegree
Filipe Pacheco
Full Stack JavaScript Techdegree Student 21,416 Points

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

can u please paste the link of code challenge

4 Answers

Simon Coates
Simon Coates
28,694 Points

try

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.

HIDAYATULLAH ARGHANDABI
HIDAYATULLAH ARGHANDABI
21,058 Points
Select * from books order by title limit 10 offset 10
SELECT * FROM books ORDER BY title ASC LIMIT 10 OFFSET 10;