Home >Database >Mysql Tutorial >What does as mean in mysql
ASAS in MySQL is a keyword used to create an alias or specify a new table name. It improves readability, avoids ambiguity, performs temporary renaming, and creates table aliases. Aliases created using AS are only valid within the current query by default, but permanent aliases can be created using the CREATE ALIAS statement.
AS in MySQL
AS is a keyword in MySQL, used Used to specify a new name for an alias or table. It allows you to create temporary or persistent names to make it easier to reference objects in queries.
Usage
Syntax:
<code class="sql">SELECT ... AS alias_name FROM ...</code>
Example:
Will The name
column of table customers
is renamed to customer_name
:
<code class="sql">SELECT name AS customer_name FROM customers;</code>
Function
Use AS Has the following advantages:
Persistence
By default, aliases created using AS are only valid within the current query. However, you can use the CREATE ALIAS statement to create a persistent alias that will persist in the database.
Syntax:
<code class="sql">CREATE ALIAS alias_name AS new_name;</code>
Example:
Create a permanent alias cust
to reference customers
table:
<code class="sql">CREATE ALIAS cust AS customers;</code>
Now you can use cust
as an alias for the customers
table:
<code class="sql">SELECT * FROM cust;</code>
The above is the detailed content of What does as mean in mysql. For more information, please follow other related articles on the PHP Chinese website!