使用"AS"有什么意义?如果没有别名就可以在SQL中使用关键字吗? [英] What is the point using "AS" keyword in SQL when aliasing can be done without it?

查看:103
本文介绍了使用"AS"有什么意义?如果没有别名就可以在SQL中使用关键字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 从员工那里选择薪水* 12作为年薪";
  2. 从员工那里选择薪水* 12年薪";

两个查询都将给出相同的结果,"AS"会有所不同吗?如果是,那是什么?如果没有,那么使用它有什么意义呢?

Both queries will give the same result, would "AS" make some difference? if yes, what it is? if no, then what is point using it?

推荐答案

我认为原因很简单.考虑如下代码:

I think the reason is simple. Consider code such as the following:

select a, b, c, d
. . .

偶尔跳过逗号很容易:

select a b, c, d

如果您不使用as,那么这看起来像是正确的代码,可能很难弄清楚.如果您总是使用as作为列别名,那么您知道它是错误的.

If you don't use as then this looks like correct code and it can be difficult to figure out. If you always use as for column aliases, then you know it is incorrect.

这篇关于使用"AS"有什么意义?如果没有别名就可以在SQL中使用关键字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆