MYSQL database - alias definition table and fields

Alias ​​definition tables and fields

In the query may be an alias for the tables and fields, this alias can be substituted for the specified table and field. Table alias for the field and can make queries easier. And it can display the query results in a more reasonable manner.

Table alias

When the name of a particularly long table, the table name in the query directly inconvenient. A case can take appropriate alias table.

example:

SELECT * from info i where i.age=33;

search result:

MYSQL database - alias definition table and fields

Alias ​​for the field

When the query data, MySQL will show the term of each output column. By default, the column name is displayed in the column name defined when creating tables. We can also take an alias for the column.

example:

SELECT score as s ,age as a from info;

MYSQL database - alias definition table and fields

SELECT score s, age a from info; #as may be omitted

MYSQL database - alias definition table and fields

Guess you like

Origin blog.51cto.com/13760351/2472615