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


SQL Basics

We're using a database on a smartphone again. We have a phone_book table. In here there's an id, first_name, last_name and phone. As the user types the phone number in we want to show possible autocomplete values. Bring back only the phone numbers of each contact only. Our smartphone can work out which of the results to show.

Please let me know what will be the SQL statement for this question?

gareth o'connor
gareth o'connor
1,755 Points

could do with more context but a basic query like the below could do the trick:

select phone from phone_book where phone like '<user_input>%';

1 Answer

Do not get confused by the:

Bring back only the phone numbers of each contact only.

The answer is simple.

select phone from phone_book;