为什么在 Oracle 中,当我们从别名获取值时,我们无法将列指定为别名?
对于前。 我的查询:
select *
from
(SELECT distinct b.lname||' '||b.fname as "Manager",b.EMPID as "Mgrid"
from EMPLOYEE1) a,
(select lname,fname,empid from EMPLOYEE1) b
where b.EMPID=a.MGRID)
正在获取,
Manager Mgrid
---------------- --------
Farooque Umer 104
Sontireddy Kiran 107
Chopra Bhupendra 103
但我无法写入:
select Manager, Mgrid
from
(select distinct b.lname||' '||b.fname as "Manager",b.EMPID as "Mgrid"
from EMPLOYEE1) a,
(select lname,fname,empid
from EMPLOYEE1) b
where b.EMPID=a.MGRID)
错误:
[错误] 脚本行:1-1 -------------------------- ORA-00904: “MGRID”: 无效标识符
For ex.
My query :
select *
from
(SELECT distinct b.lname||' '||b.fname as "Manager",b.EMPID as "Mgrid"
from EMPLOYEE1) a,
(select lname,fname,empid from EMPLOYEE1) b
where b.EMPID=a.MGRID)
is fetching
Manager Mgrid
---------------- --------
Farooque Umer 104
Sontireddy Kiran 107
Chopra Bhupendra 103
but I cant write :
select Manager, Mgrid
from
(select distinct b.lname||' '||b.fname as "Manager",b.EMPID as "Mgrid"
from EMPLOYEE1) a,
(select lname,fname,empid
from EMPLOYEE1) b
where b.EMPID=a.MGRID)
Error:
[Error] Script lines: 1-1 --------------------------
ORA-00904: "MGRID": invalid identifier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为一旦您开始将名称括在双引号(例如“Mgrid”)中,它们就会区分大小写。所以不要。这样做:
或者如果你真的喜欢区分大小写的名称,你必须这样做:
Because as soon as you start enclosing names in double quotes like "Mgrid" they becone case-sensitive. So don't. Do this:
or if you really like case-sensitive names you must do this:
您应该只在顶层选择应用修饰字段命名 - 所有其他标识符都应保留为有效的 Oracle 标识符。
You should only apply cosmetic field naming at the top level select - all other identifiers should be kept as valid Oracle identifiers.
除了引号之外,我认为您的帖子还多了一个括号:
Besides the quotes, I think your post contains one more parenthesis than needed: