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

Nathan Hering
Nathan Hering
4,506 Points

Limit and Offset, Having trouble with these challenges

Why does it return ( Bummer! Your query needs to retrive the earliest 'Science Fiction' book from the books table) when the challenge was to bring back the second page of results and nothing to do with the genre or first_published? I'm lost on this one. Any help would be great.

Simon Coates
Simon Coates
28,694 Points

It's possible to link forum topics to a challenge or video. Otherwise, a URL to the video or challenge can help people verify things.

3 Answers

Nathan Hering
Nathan Hering
4,506 Points

Here's the challenge: Note: We will be writing ONLY the SQL query for this challenge. 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.

Here's my code: SELECT title, author, genre, first_published FROM books ORDER BY title LIMIT 10 OFFSET 10;

Simon Coates
Simon Coates
28,694 Points

Try here. You just need to replace the fields with a *. The message it's giving you is gibberish i think. I'm pretty sure i complained a few months back about that exact message.

Nathan Hering
Nathan Hering
4,506 Points

So I tried:

select * from books where genre = 'Science Fiction' order by title limit 10 offset 2;

And now the result is:

Bummer! Ten books were expected. 4 were returned in the results.

I just moved on. There seems to be something wrong with this challenge.

Simon Coates
Simon Coates
28,694 Points

I've seen a couple challenges where the message you get back are flat out wrong, and a couple (particularly with SQL) when the question is messed up. If you hit something that's a legitimate glitch, hit the forum, but be aware that it may flat out be a bad message or faulty question. If so, you should email treehouse about it. On one occasion, i spent a month stuck on a single challenge with incorrect instructions. I got it right in the end by assuming that they hadn't given me a complete set of information. Whether or not treehouse fixes the glitch (they tell you it's been forwarded to the teaching team), it's cathartic to vent.

Simon Coates
Simon Coates
28,694 Points

the science fiction thing is a mistake. I already emailed treehouse about it messing students around. if you'r working on the challenge i think you're working on:

select title, author, genre, first_published from books order by title limit 10 offset 10;

gets you the science fiction message

select * from books order by title limit 10 offset 10;

does not. (and the first results you get back seem to be a genre of fantasy.)