当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL Aliases
With SQL, aliases can be used for column names and table names.
通过SQL语句,可以将返回结果的栏目名或是表名重命名
语法:
SELECT column AS column_alias FROM table |
语法:
SELECT column FROM table AS table_alias |
Person数据表:
LastName | FirstName | Address | City |
---|---|---|---|
Hansen | Ola | Timoteivn 10 | Sandnes |
Svendson | Tove | Borgvn 23 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
SQL语句为:
SELECT LastName AS Family, FirstName AS Name |
返回的结果为:
Family | Name |
---|---|
Hansen | Ola |
Svendson | Tove |
Pettersen | Kari |
Person数据表:
LastName | FirstName | Address | City |
---|---|---|---|
Hansen | Ola | Timoteivn 10 | Sandnes |
Svendson | Tove | Borgvn 23 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
SQL语句:
SELECT LastName, FirstName |
返回的结果为:
表名换成了Employees:
LastName | FirstName |
---|---|
Hansen | Ola |
Svendson | Tove |
Pettersen | Kari |