Has been very strange, do not know why SQL alias how to use, last saw thinkphp in the explanation, why the database in use sometimes like to change the name of the use,
Because yesterday to participate in the company's database development Engineer's written test, today to review SQL, see the role of SQL Alias, the following is his/her role in the use of Alias
To know when he used it was better.
Let's say we have two tables: "Persons" and "Product_orders", respectively. We assign them the alias "P" and "Po", respectively.
Now we want to list all orders for "John Adams".
We can use the following SELECT statement:
1 SELECT Po. OrderID, P.lastname, P.firstname2 from as as po3WHERE p.lastname='Adams' and P.firstname=' John'
SELECT statements that do not use aliases:
1 SELECT Product_orders.orderid, Persons.lastname, Persons.firstname 2 from Persons, Product_orders 3 WHERE Persons.lastname='Adams' and persons.firstname= ' John '
How to use alias in SQL