0
0
MySQLquery~5 mins

Table aliases in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a table alias in SQL?
A table alias is a temporary name given to a table in a query to make it easier to reference, especially when using joins or long table names.
Click to reveal answer
beginner
How do you assign an alias to a table in a SQL query?
You write the table name followed by the alias name, usually separated by a space. For example: FROM employees e assigns the alias e to the employees table.
Click to reveal answer
beginner
Why use table aliases in SQL queries?
Table aliases make queries shorter and easier to read. They help when joining multiple tables by clarifying which table each column belongs to.
Click to reveal answer
beginner
Can table aliases be used in the SELECT clause?
Yes, once a table has an alias, you use that alias to refer to its columns in the SELECT clause and elsewhere in the query.
Click to reveal answer
beginner
Is the alias name permanent in the database?
No, aliases only exist for the duration of the query. They do not change the actual table names in the database.
Click to reveal answer
What does this SQL snippet do? <br>SELECT e.name FROM employees e;
AFilters employees by name 'e'
BCreates a new table named 'e'
CRenames the employees table permanently to 'e'
DAssigns 'e' as an alias for the employees table
Why are table aliases useful in queries with multiple tables?
AThey make the query run faster
BThey help distinguish columns from different tables
CThey permanently rename tables
DThey create new tables
Which of these is a correct way to alias a table?
AFROM employees AS e
BFROM employees TO e
CFROM employees RENAME e
DFROM employees WITH e
If you alias a table as 'c', how do you select the column 'city' from it?
ASELECT city FROM c
BSELECT city.c FROM c
CSELECT c.city FROM c
DSELECT c FROM city
Do table aliases affect the actual table names in the database?
ANo, aliases only exist during the query
BNo, they create copies of tables
CYes, but only temporarily
DYes, they rename tables permanently
Explain what a table alias is and why it is useful in SQL queries.
Think about how you might shorten a long name to make talking easier.
You got /4 concepts.
    Describe how to write a SQL query that uses a table alias and how to refer to columns using that alias.
    Remember the format: FROM table AS alias
    You got /4 concepts.