Home >Backend Development >PHP Tutorial >An explanation of SQL Alias ​​(alias) in php

An explanation of SQL Alias ​​(alias) in php

jacklove
jackloveOriginal
2018-05-08 10:11:243196browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn