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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值