表的别名
SELECT 列 FROM 表 AS 别名
列的别名
SELECT 列 AS 别名FROM 表
例:表的别名
假设我们有两个表,分别是:"Persons" 和 "Product_Orders"。我们分别为它们指定别名 "p" 和 "po"
现在我们希望列出 "John Adams" 的所有定单
SELECT po.OrderID, p.LastName, p.FirstName
FROM Persons AS p, Product_Orders AS po
WHERE p.LastName='Adams' AND p.FirstName='John'
例:列的别名
表 Persons:
Id | LastName | FirstName | Address | City |
1 | Adams | John | Oxford Street | London |
2 | Bush | George | Fifth Avenue | New York |
3 | Carter | Thomas | Changan Street | Beijing |
语句:
SELECT LastName AS Family, FirstName AS Name
FROM Persons
结果:
Family | Name |
Adams | John |
Bush | George |
Carter | Thomas |