别名列的不同方法 [英] Different ways to alias a column
本文介绍了别名列的不同方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从雇员
中选择empName作为EmployeeName有什么区别? / pre>
与
从雇员$ b中选择EmployeeName = empName从技术角度来看,$ b
。不知道这是否只是SQL Server专用。
欣赏您的答案。
解决方案我希望使用第一个,因为第二个不是可移植的-
select EmployeeName = empName来自员工的
是语法错误(至少在SQLite和Oracle中),或者可能不会您所期望的(比较两列EmployeeName和empName并以布尔值/整数返回比较结果),而
选择empName雇员的EmployeeName
与
<$相同p $ p>从雇员
中选择empName作为EmployeeName
这是我的首选
What is the difference between
select empName as EmployeeName from employees
versus
select EmployeeName = empName from employees
from a technical point of view. Not sure if this is just SQL server specific or not.
Appreciate your answers.
解决方案
I'd prefer the first one, since the second one is not portable -
select EmployeeName = empName from employees
is either a syntax error (at least in SQLite and Oracle), or it might not give you what you expect (comparing two columns EmployeeName and empName and returning the comparison result as a boolean/integer), whereas
select empName EmployeeName from employees
is the same as
select empName as EmployeeName from employees
which is my preferred variant.
这篇关于别名列的不同方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文