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

Databases

Rekha Iyengar
seal-mask
.a{fill-rule:evenodd;}techdegree
Rekha Iyengar
UX Design Techdegree Student 9,170 Points

What am I missing

SELECT last_name FROM phone_book WHERE phone IS NOT NULL;

Rekha Iyengar
seal-mask
.a{fill-rule:evenodd;}techdegree
Rekha Iyengar
UX Design Techdegree Student 9,170 Points

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