MySQL SQLLesson 27Free preview
MySQL Aliases
This lesson is part of MySQL · All levels
Summary
The alias temporarily names columns or tables in a query to make the results easier to read and refer to. The column aliases are written after the column name using the US keyword or directly without the US, while the table aliases help shorten the column reference to the JOIN query. The alias name is only valid as long as the query is running and does not save anything to the table.
Key points
- The alias of the column changes the name of the display on the result set, instead of the name of the original column in the table
- US keywords are optional: SELECT US price h is equal to SELECT price h
- Tables aliases shorten the writing of labeled columns such as p.nama in the JOIN query
- The alias must be used when the result of an aggregate function is to be given a clear name
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.