PostgreSQL错误:列“ MANAGER”不存在 [英] PostgreSQL error: Column "MANAGER" does not exist
问题描述
谁能告诉我这个错误为什么会弹出?我的代码有问题吗?
Can anyone please tell why is this error popping? Is there something wrong in my code?
哪个经理(ename)仅适用于与他的工作不同的员工?
Which Manager (ename) works only with employees who don't have the same job as he has?
Select e.ename
from emp e
where e.job = "MANAGER"
and e.mgr not in (select empno from emp where job = "MANAGER")
错误查询中:FEHLER:Spalte >> MANAGER<<第1行:从emp e中选择e.ename,其中e.job = MANAGER和e.mgr ...
Error in query: FEHLER: Spalte >>MANAGER<< existiert nicht LINE 1: Select e.ename from emp e where e.job = "MANAGER" and e.mgr ...
图片:
< img src = https://i.stack.imgur.com/LHn4S.png alt =在此处输入图片描述>
推荐答案
您的字符串文字应使用单引号而不是双引号引起。
Your string literals should be enclosed in single quotes instead of double quotes.
SELECT e.ename
FROM emp e
WHERE e.job = 'MANAGER'
AND e.mgr NOT IN(SELECT empno
FROM emp
WHERE job = 'MANAGER');
此外,根据您的标题,我想知道该查询是否应该更一般地写入帐户有什么共同点吗?
Also, based on your title, I wonder if this query shouldn't be written more generically to account for any job in common? Something like:
SELECT e.ename
FROM emp e
WHERE NOT EXISTS(SELECT 1
FROM emp em
WHERE em.empno = e.mgr
AND em.job = e.job);
这篇关于PostgreSQL错误:列“ MANAGER”不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!