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 trialAlanis Chua
2,830 Pointssql challenge 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.
SELECT last_name FROM phone
how to get the missing information when i am not given a value?
1 Answer
Steven Parker
231,236 PointsThe instructions say, "Write a query to retrieve all values from the last name column where the last name value is present." This suggests that not every row will contain a last name. So to handle this, you can add a "WHERE
" clause to your query to select only the rows where the "last_name" field is not NULL
.
Also, the instructions asked for "all values", so instead of selecting only the "last_name" field, you might use the wildcard "*" to represent all the values on each row.
In future questions, for the most accurate answers always include a link to the course page you are working with.