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

I don't know what I'm doing wrong with my SQL code

It wants me to find the longest length title in the books category and I did just that but its telling me that I haven't retrieved the book with its length. Yet when I look I clearly have

The challenge is in PHP Intermediate Getting The Length of a String task and my code is

SELECT title,LENGTH(title) AS "length calculation" FROM books ORDER BY LENGTH(title) DESC LIMIT 1;

1 Answer

Corey Montgomery
Corey Montgomery
18,468 Points

The problem looks to be that the instructions are asking for "longest_length" and you are calling the field "length calculation." Swap those around and it should pass just fine. Here is the code:

SELECT title,LENGTH(title) AS longest_length FROM books ORDER BY LENGTH(title) DESC LIMIT 1;

Hope that helps.