as用法4

sql语句中select……as的用法

分类: 数据库学习   3920人阅读  评论(0)  收藏  举报
<strong><span style="color: rgb(51, 51, 51);">as   可理解为:用作、当成,作为;</span><span style="color: rgb(255, 0, 0);">一般是重命名列名或者表名</span><span style="color: rgb(51, 51, 51);">。</span></strong><span style="color: rgb(51, 51, 51);">
1.例如有表table,  列 column_1,column_2  
你可以写成 select  column_1  as  列1,column_2 as  列2   from  table  as  表
上面的语句就可以解释为,选择 column_1  作为  列1,column_2 作为   列2  从 table  当成 表</span>
<span style="color: rgb(51, 51, 51);">
</span>
2.<pre id="answer-content-800959615" class="answer-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);">SELECT * FROM Employee AS emp
这句意思是查找所有Employee 表里面的数据,并把Employee表格命名为 emp。
当你命名一个表之后,你可以在下面用 emp 代替 Employee.
例如 SELECT * FROM emp.
</pre><pre id="answer-content-800959615" class="answer-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255);">3.<pre id="answer-content-800972086" class="answer-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; background-color: rgb(255, 255, 255);">把查询对像起个别名的作用。
select ID as 用户ID,Name as 用户名 from Table_user

查出结果就以中文显示
select * from tb_user as mytableA join 
select * from Tb_UserGroup as mytableB
on mytableA.ID=mytableB.ID。这样就可以把查询结果起别名
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值