Learn SQL: AS
Renaming columns
Lien is putting together an overview for the newsletter. "Column headers like member_since? We can do better than that."
Renaming columns with AS
With AS you give a column a different name in your result. Such a name is called an alias.
Look at the column headers: name is called coffee here and price is called euros. The table itself doesn't change.
SELECT name AS coffee, price AS euros FROM products LIMIT 4| coffee | euros |
|---|---|
| House Blend | 12.5 |
| Ethiopia Yirgacheffe | 16.9 |
| Colombia Huila | 14.75 |
| Espresso Forte | 11.95 |
Try it yourself
Show the name of each product, but call the column product.
Ready for more?
The full lesson has 6 exercises, from easy to challenging, with hints, points and a streak you can build.
Start the lesson