0
0
MySQLquery~5 mins

Column aliases in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a column alias in SQL?
A column alias is a temporary name given to a column in the result set of a query to make the output easier to read or understand.
Click to reveal answer
beginner
How do you assign a column alias in a SELECT statement?
You use the AS keyword followed by the alias name after the column name, like: SELECT column_name AS alias_name FROM table;
Click to reveal answer
intermediate
Can you use column aliases without the AS keyword?
Yes, in many SQL databases including MySQL, you can write the alias directly after the column name with a space, like: SELECT column_name alias_name FROM table;
Click to reveal answer
beginner
Why use column aliases in SQL queries?
Column aliases make output easier to read, especially when columns have complex names or expressions. They also help when combining columns or using functions.
Click to reveal answer
intermediate
Give an example of a column alias with a calculation.
Example: SELECT price, quantity, price * quantity AS total_cost FROM sales; This shows total_cost as the alias for the calculation.
Click to reveal answer
Which keyword is commonly used to assign a column alias in SQL?
AALIAS
BAS
CRENAME
DLABEL
What will this query return? SELECT price * quantity AS total FROM sales;
AA column named total with the product of price and quantity
BAn error because AS cannot be used with calculations
CThe original price column only
DThe original quantity column only
Is this query valid in MySQL? SELECT name full_name FROM users;
ANo, alias must be in quotes
BNo, AS is required
CNo, alias must be after FROM
DYes, alias without AS is allowed
Why might you use a column alias in a query?
ATo make column names easier to understand in the output
BTo change the actual column name in the table
CTo delete a column from the table
DTo create a new table
Which of these is a correct way to alias a column?
ASELECT age ASuser_age FROM people;
BSELECT age user_age FROM people;
CBoth B and D
DSELECT age AS user_age FROM people;
Explain what a column alias is and how to use it in a SQL SELECT query.
Think about giving a temporary name to a column in your query output.
You got /3 concepts.
    Describe why column aliases are helpful when working with SQL queries.
    Consider how query results look to someone reading them.
    You got /3 concepts.