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!
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
Christopher FranklinCourses Plus Student 440 Points
Why would you want to Alias a column name? Does this actually change the name of the column in the database?
I'm just not sure why you would want to do this, and if it changes the name of the column in the data base or if it just changes the name for your results. What would be a real world example of this.
Jason AndersTreehouse Moderator 145,855 Points
First off, no, aliasing a column will not change the name of it in the database. It doesn't affect the database at all, in any way. You mostly alias to make your output much easier to read and understand.
A real world example could be:
You have a database that stores all the movies a store has available for purchase. In that database they use a column for the year the movie was released named
movie_released_year. While this is fine for the database, it not very readable for the user if they were to pull up the data on a website. Therefore, you would alias that column in the query as "Year Released" ... much more clear and user friendly. It's really all about the UX (User Experience).
Cindy LeaCourses Plus Student 6,497 Points
You can create aliases for column names to make it easier to work with column names, calculations, and summary values. For example, you can create a column alias to: Create a column name, such as "Total Amount," for an expression such as (quantity * unit_price) or for an aggregate function.
Thomas Nilsen14,957 Points
One really good reason why you would want to (and have to) alias columns is:
Let's say you have two table - TABLE A and TABLE B. You want to join these together.
SELECT ID FROM TABLE_A AS A JOIN TABLE_B AS B ON B.ID = A.ID
The example above would not work, since the column ID exists on both TABLE_A and TABLE_B and sql don't know which one of those you intended to use.
you would have to write either
BUT a new problem would occur id you were to do this:
SELECT ZZ.ID /*this wouldnt work because both of them is called ID You have rename them to for example 'A.ID as A_ID' and 'B.ID as B_ID'*/ FROM ( SELECT A.ID, B.ID FROM TABLE_A AS A JOIN TABLE_B AS B ON B.ID = A.ID ) ZZ
The answer is at the 4:00 mark of the video
Well at 4 yeah. In the realm of sigma script. You could develop personality. For ux. Ux this. Customer experience. Involvement really. Emotional response.v It's not just to hide your layer of a actual machine. Flavor. I don't know if font comes out of that equation down the processes. Like have you ever found phone lines are predictable on certain intervals.