The use of the alias (alias) on SQL. There are two types of aliases that are most commonly used: field aliases and table aliases.
Simply put, the purpose of the field alias is to make the results of SQL generated easy to read . In the previous example, the field name is SUM (sales) whenever we have a total turnover. Although there is no problem in this case, if the field is not a simple summation, but a complex calculation, then the column name is not so easy to understand. If we use field aliases, we can confirm that the field names in the results are easy to understand.
The second type of alias is the table alias. To give a table an alias, simply empty a grid after the table name in the FROM clause, and then list the table aliases you want to use. This is handy when we want to use SQL to get data from several different tables. This is what we'll see later when we talk about join.
Let's take a look at the syntax for field aliases and table aliases:
Select from "Table name" "Table alias";
Basically, both of these aliases are placed behind the objects they are replacing, and they are separated by a blank space. We continue to use the store_information form to do an example:
We use the same example as the SQL GROUP by page. The difference here is that we've added field aliases and table aliases:
SELECT SUM ' Total Sales ' from store_information A1 GROUP by A1. Store_name;
Los Angeles 1800San Diego Boston
In the results, the information itself is not different. The difference is the title of the field. This is the result of applying a field alias. In the second field, we originally had the title "Sum", and now we have a very clear "total sales". It is clear that total sales can describe the meaning of this field more precisely than Sum (sales). The benefits of using table aliases don't show up here.
sql-aliases alias (AS)