Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases

SQL BASICS

Challenge Task 1 of 4 We're back in our e-commerce database. There's a products table with the columns id, name, description and price. Can you retrieve both the name and description aliased as "Product Name" and "Product Description".

The columns you selected were named "Product Name", "Product Description" and not
'Product Name' and 'Product Description'.

6 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Challenge Task 1

We're back in our e-commerce database. There's a products table with the columns id, name, description and price.

Can you retrieve both the name and description aliased as "Product Name" and "Product Description".

SELECT name AS "Product Name", description AS "Product Description" FROM products;

Let me know if you are still stuck.

Ken

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Ary;

The basic syntax in SQL for using AS would be:

SELECT name AS "Some other name" FROM table;

If we want to do multiple AS statements we separate them with a comma, just like selecting multiple bits of data, right?

SELECT name_one AS "Name One", name_two AS "Name Two" FROM name_table;

Does that make any sense? You don't want to wrap your column names in the quotes.

Post back if you are still stuck.

Happy coding,
Ken

Mr Ken Cool... SELECT name AS "Product Name", description AS "Product Description" FROM products;

my answer SELECT "Product Name AS Product Description", "Product Description" FROM products;

SELECT Product Name AS "Product Description", "Product Description" FROM products;

SQL Error: near "AS": syntax error

No

SELECT product_name AS "Product Description" FROM products;

SQL Error: near "&": syntax error