Home >Backend Development >PHP Tutorial >An explanation of SQL Alias (alias) in php
SQL Alias
SQL Alias syntax for tables
SELECT column_name(s) FROM table_name AS alias_name
SQL Alias syntax for columns
SELECT column_name AS alias_name FROM table_name
Alias Example: Using table name alias
Suppose we There are two tables: "Persons" and "Product_Orders". We give them the aliases "p" and "po" respectively.
Now, we want to list all orders for "John Adams".
We can use the following SELECT statement:
SELECT po.OrderID, p.LastName, p.FirstName FROM Persons AS p, Product_Orders AS poWHERE p.LastName='Adams' AND p.FirstName='John'
SELECT statement without alias:
SELECT Product_Orders.OrderID, Persons.LastName, Persons.FirstName FROM Persons, Product_Orders WHERE Persons.LastName='Adams' AND Persons.FirstName='John'
As you can see from the above two SELECT statements, the alias is queryThe program is easier to read and write.
This article explains SQL Alias (alias) in php. For more learning materials, please pay attention to the php Chinese website.
Related recommendations:
How to use the SQL BETWEEN operator
How to use the SQL IN operator
Explanation of SQL wildcard related knowledge
The above is the detailed content of An explanation of SQL Alias (alias) in php. For more information, please follow other related articles on the PHP Chinese website!