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 trialAry de Oliveira
28,298 PointsSQL Basic Databases
Challenge Task 3 of 4 We're now back with the smartphone database. In the phone_book we have the columns id, first_name, last_name and phone. Alias the first and last names and phone as "First Name", "Last Name" and "Phone Number".
MY CODE:
SELECT 'First Name', 'Last Name',phone AS "Phone Number" FROM phone_book;
The columns you selected were named 'First Name', 'Last Name', Phone Number and not 'First Name', 'Last Name' and 'Phone Number'.
5 Answers
Steven Parker
231,261 PointsYou forgot to reference the first two columns, first_name and last_name. The AS keyword is optional, but it's probably good to get into the habit of being consistent. Try:
SELECT first_Name AS "First Name", last_Name AS "Last Name", phone AS "Phone Number" FROM phone_book;
This would also work:
SELECT first_Name "First Name", last_Name "Last Name", phone "Phone Number" FROM phone_book;
mkmk
15,897 PointsYou only aliased phone to Phone Number.
You must alias each of the three columns separately. ie. column AS new name, column2 AS new name 2 etc
Ary de Oliveira
28,298 PointsSELECT 'first_name' AS 'First Name', 'last_name' AS 'Last Name', 'phone' AS 'Phone Number' FROM phone_book;
Ary de Oliveira
28,298 PointsMY CODE
SELECT 'First Name', 'Last Name',phone AS "Phone Number" FROM phone_book;
Hayley Risley
9,510 PointsIf anyone is still having issues this is the code that worked for me: SELECT * FROM phone_book WHERE phone IS NULL;
Roberto Rivera
10,832 PointsWe're back on the smartphone, but our phone_book is a mess. There's a phone_book table but there's missing information in a couple of the columns. The phone_book has the following columns id, first_name, last_name and phone. Find all contacts in the phone_book where the phone number is missing so we can go and ask them for their number.
Imputing this should be right. It's not asking for any other information. Plus the NOT NULL query should place all names on the column, right? Is this syntax correct or not? Maybe there's a bug. I'm not understanding why the contacts don't show. SELECT first_name, last_name FROM phone_book WHERE id IS NOT NULL;