Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases

What am I missing

SELECT last_name FROM phone_book WHERE phone IS NOT NULL;

Sorry here is the question.

We're still using the phone_book, with the columns id, first_name, last_name and phone. Imagine we're implementing the autocomplete feature for a search box where you can start typing in someone's last name and suggestions will appear. Retrieve all non-NULL values from the last name column. Only retrieve the last_name column.

4 Answers

Shayan Khan
Shayan Khan
9,842 Points

This Worked for me:

SELECT * last_name FROM phone_book WHERE last_name IS NOT NULL;

Hope that helps out.

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

Why do you select last_name, if you already selected all?

Shayan Khan
Shayan Khan
9,842 Points

I'm sorry, my mistake. It was supposed to be SELECT last_name FROM phone_book WHERE last_name IS NOT NULL. The question specifically asks us to only to retrieve the last name column and therefore, we need to write SELECT last_name FROM phone_book. And then write the condition to retrieve all the NON Null values in the last_name column which is WHERE last_name IS NOT NULL;. Hope that helps out!

Not sure what the question is but if its the one I think it is, its asking you to return everything WHERE phone IS NOT NULL not just last_name.

If that is the case it should be:

SELECT * FROM phone_book WHERE phone IS NOT NULL;
Sergey Podgornyy
Sergey Podgornyy
20,660 Points

It looks correct and should work properly

Thanks So much! =)