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

Challenge Task 1. Need help with the SQL query

I've written SELECT * FROM products;

it tells me to write SELECT? Please help. Thanks.

This is the task: 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 facility on the phone where a user can start typing a last name and suggestions will appear. Write a query to retrieve all values from the last name column where the last name value is present. Only retrieve the last_name column.

This's my answer: SELECT * FROM phone_book WHERE last_name IS NOT NULL;

This's the result from my answer above: Bummer! Did you test the last_name column from the phone_book table to see if it's not NULL?

6 Answers

Brandon Hartman
Brandon Hartman
8,032 Points

Can you link the question to the task so we can take a look at it? It may be a error the challenge.

Nicholas Ivezic
Nicholas Ivezic
2,791 Points

I am also receiving the same error. I would appreciate your help, Brandon. Thanks!

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 facility on the phone where a user can start typing a last name and suggestions will appear. Write a query to retrieve all values from the last name column where the last name value is present. Only retrieve the last_name column

SELECT * FROM phone_book WHERE last_name IS NOT NULL;

 Bummer! Did you test the `last_name` column from the `phone_book` table to see if it's not NULL?
caio França Lima
caio França Lima
365 Points

can you tell me how to fix this ? i opened a ticket about this same question and i'm waiting to pass this chalenge.

tryed with SELECT * FROM phone_book WHERE last_name IS NOT NULL

but returns me a message of error like that : Bummer! Did you test the last_name column from the phone_book table to see if it's not NULL? Where am i doing wrong ?

Nicholas Ivezic
Nicholas Ivezic
2,791 Points

I figured it out, it has been worded poorly. From SQL Basics: Filtering Out or Finding Missing Information. (2 Objectives)

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 facility on the phone where a user can start typing a last name and suggestions will appear. Write a query to retrieve all values from the last name column where the last name value is present. Only retrieve the last_name column.

They are asking for information exclusively from the last name column, not information from all columns. With that, SELECT last_name, rather than SELECT *.

ANSWER: SELECT last_name FROM phone_book WHERE last_name IS NOT NULL;

Cheers

Nicholas Ivezic
Nicholas Ivezic
2,791 Points

I figured it out, it has been worded poorly. From SQL Basics: Filtering Out or Finding Missing Information. (2 Objectives)

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 facility on the phone where a user can start typing a last name and suggestions will appear. Write a query to retrieve all values from the last name column where the last name value is present. Only retrieve the last_name column.

They are asking for information exclusively from the last name column, not information from all columns. With that, SELECT last_name, rather than SELECT *.

ANSWER: SELECT last_name FROM phone_book WHERE last_name IS NOT NULL;

Cheers

Ladislav Vysmek
Ladislav Vysmek
999 Points

SELECT last_name FROM phone_book WHERE last_name IS NOT NULL;

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi all,

The last sentence says to "Only retrieve the last_name column."

You're not required to bring back all columns with *

caio França Lima
caio França Lima
365 Points

Thank you Andrew but i got the challenge first kk thx your attention

chase singhofen
chase singhofen
3,811 Points

thx didnt even think to use the last_name twice. and omit the *

Dear all, I've the same problem too, please advise.

caio França Lima
caio França Lima
365 Points

I have the same problem here, the query are correct ,isn't ? i'm usying the query : SELECT * FROM phone_book WHERE last_name IS NOT NULL from the question, but are returning this error message, what can we do to fix this question ?

Graham Patrick
Graham Patrick
8,294 Points

This should be spot on here

SELECT last_name FROM phone_book WHERE last_name IS NOT NULL;

Nader Habib
Nader Habib
1,106 Points

SELECT * FROM phone_book WHERE last_name IS NOT NULL;

Where is the error

Did you test the phone column from the phone_book table to see if it's NULL?