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

Julie Dowler
Julie Dowler
7,851 Points

Why won't it accept this?

Here is the challenge question:

Challenge Task 1 of 2

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.

I run this query, and it appears to have done just what it is supposed to do: retreive the second ten items from the database after sorting the database in alphabetical order by title. Yet, it gives me an error. It says "Your query needs to retrieve the books 11 through 20 from the database when ordered by title, check the OFFSET."

7 Answers

Patrik Horváth
Patrik Horváth
11,110 Points

Hi Julie Dowler and your query is where ?

also you can give ORDER BY ASC but ASC is Default Value

SELECT * FROM books ORDER BY title LIMIT 10 OFFSET 10;

or i preffer this its more clear LIMIT how manny SKIP, How manny show :)

SELECT * FROM books ORDER BY title LIMIT 10,10;

Challange 1 of 2 :

SELECT * FROM books ORDER BY title LIMIT 10,10;

Challange 2 of 2 :

SELECT * FROM phone_book ORDER BY last_name, first_name LIMIT 40,20;
Julie Dowler
Julie Dowler
7,851 Points

It didn't display my code. Here it is:

SELECT * FROM books ORDER BY REPLACE(REPLACE(REPLACE(title,'The ',''),'An ',''),'A ','') LIMIT 10 OFFSET 10

The things that look like double quotes are actually two single quotes, indicating the empty set.

Patrik Horváth
Patrik Horváth
11,110 Points

use my Query :) and idk whot you wanted to make xD but its wrong :), after ORDER BY table.column

Patrik Horváth
Patrik Horváth
11,110 Points

my query works, idk where is problem on your side

Challange 1 of 2 :

SELECT * FROM books ORDER BY title LIMIT 10,10;

Challange 2 of 2 :

SELECT * FROM phone_book ORDER BY last_name, first_name LIMIT 40,20;
Julie Dowler
Julie Dowler
7,851 Points

Omg now it took it! I swear it's the same query I entered two days ago.

Patrik Horváth
Patrik Horváth
11,110 Points

xD but i tested it by my own it works

Julie Dowler
Julie Dowler
7,851 Points

I tried yours and it doesn't work.

Julie Dowler
Julie Dowler
7,851 Points

I wonder if Alena Holligan has any idea why this won't work.