SQL语句Alias

SQL Alias

表的 SQL Alias 语法

SELECT COLUMN_NAME(S) FROM TABLE_NAME AS ALIAS_NAME

列的 SQL Alias 语法

SELECT COLUMN_NAME AS ALIAS_NAME FROM TABLE_NAME

CAR表:

VINBRANDMODELPRICEPRODUCTION_YEAR
LJCPCBLCX14500264FordFocus80002005
WPOZZZ79ZTS372128FordFusion100002008
JF1BR93D7BG498281ToyotaAvensis100001999
KLATF08Y1VB363636VolkswagenGolf30001992
1M8GDM9AXKP042788VolkswagenGolf100002010
1HGCM82633A004352VolkswagenJetta60002003
1G1YZ23J9P5800003FiatPunto60001999
GS723HDSAK2399002OpelCorsa89000.002007
LP859CCSRH5555963ToyotaAvensis12000.002009
LP859CCSRH5555962OpelPunto13000.002012

BICYCLE表:

IDENTIFIERALIASBRANDPRICEPRODUCTION_YEAR
AKSLNF355小红单车Mobike1.002015
BVSLNF385小黄单车Ofo1.002015

– Alias 实例: 使用表名称别名
我们有两张表CAR和BICYCLE,分别指定别名C和B,
我们列出BRAND为’Mobike’和’Ford’的数据

SELECT CAR.VIN,BICYCLE.IDENTIFIER,CAR.MODEL,BICYCLE.ALIAS,BICYCLE.BRAND,BICYCLE.PRODUCTION_YEAR FROM CAR,BICYCLE WHERE CAR.BRAND='Ford' AND BICYCLE.BRAND='Mobike';

使用别名:

SELECT C.VIN,B.IDENTIFIER,C.MODEL,B.ALIAS,B.BRAND,B.PRODUCTION_YEAR FROM CAR AS C,BICYCLE AS B WHERE C.BRAND='Ford' AND B.BRAND='Mobike';

PS:在使用别名的时候有的不支持AS

SELECT C.VIN,B.IDENTIFIER,C.MODEL,B.ALIAS,B.BRAND,B.PRODUCTION_YEAR FROM CAR C,BICYCLE B WHERE C.BRAND='Ford' AND B.BRAND='Mobike';

结果:

VINIDENTIFIERMODELALIASBRANDPRICEPRODUCTION_YEAR
LJCPCBLCX14500264AKSLNF355Focus小红单车Mobike1.002015
WPOZZZ79ZTS372128AKSLNF355Fusion小黄单车Ofo1.002015
    原文作者:SQL
    原文地址: https://blog.csdn.net/qq229200/article/details/62039610
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞