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

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

jacklove
Release: 2023-03-25 15:30:01
Original
3197 people have browsed it

SQL Alias

SQL Alias ​​syntax for tables

SELECT column_name(s)
FROM table_name
AS alias_name
Copy after login

SQL Alias ​​syntax for columns

SELECT column_name AS alias_name
FROM table_name
Copy after login

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'
Copy after login

SELECT statement without alias:

SELECT Product_Orders.OrderID, Persons.LastName, Persons.FirstName
FROM Persons, Product_Orders
WHERE Persons.LastName='Adams' AND Persons.FirstName='John'
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template