sql语句中as的意思是什么

sql语句中as的意思是什么

sql语句中as的意思是别名,或者说给显示的结果改名。比如,select name as 姓名 from student.

意思是查询student表中的name字段,但是在显示的时候显示姓名(而不是表中的name)

还比如下面:concat(path,',',id)函数用","把前后字段【path和id】连接起来形成一个新字段   改名为fullpath

select id,catename,path,concat(path,',',id) as fullpath from likecate where 1 order by fullpath asc.

扩展资料:

as 一般用在两个地方,一个是query的时候,用来重新指定返回的column(列) 名字

如:一个table 有个column叫 id, 我们的query是

select id from table1. 但是如果你不想叫id了,就可以重新命名,如叫 systemID 就可以这样写

select id as systemId from table1;

还有一个用法就是在create table 或 procedure 的时候,as 是个关键字。

例如

create table test as select * from table1

这时候就会create 一个table test,他是完全copy 表table1里的全部数据。

create procdure name as (is)

begin

end;

具体可以参考 如何建立procedure。 这个时候 as 和is可以互换。

参考资料:百度百科-sql语句

温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-07-12
别名,或者说给显示的结果改名。比如,select name as 姓名 from student.
意思是查询student表中的name字段,但是在显示的时候显示姓名(而不是表中的name)
第2个回答  2010-07-12
as在英语里是作为的意思,在SQL语句中的话要看出现的位置了.
很多时候作为别名定义使用,例如在select选择列表中作为字段名的别名,或者多表连接时作为表的别名.
select student_name as 学生姓名 from tablename
select t1.sname,t2.sname from tablename as t1 join tablename as t2 on t1.id=t2.id
另外在一些ddl语句中也会用到,例如视图的定义:
create view vew_title
as
select * from tablename where name='abc'
这里就不做别名解了
第3个回答  推荐于2017-09-18
as 一般用在两个地方,一个是query的时候,用来重新指定返回的column 名字
如:一个table 有个column叫 id, 我们的query是
select id from table1. 但是如果你不想叫id了,就可以重新命名,如叫 systemID 就可以这样写
select id as systemId from table1;

还有一个用法就是在create table 或 procedure 的时候,as 是个关键字。
例如
create table test as select * from table1
这时候就会create 一个table test,他是完全copy table table1里的全部数据。

create procdure name as (is)
begin
end;
具体可以参考 如何建立procedure。 这个时候 as 和is可以互换。本回答被提问者采纳
第4个回答  2010-07-12
别名的意思,比如select tableA.Id from table1 as tableA
相似回答