如果没有,Oracle缺少括号

时间:2012-10-21 17:09:48

标签: sql exists oracle9i

SELECT company_name
FROM empl_company s
WHERE NOT EXISTS 
(
    (SELECT city
     FROM empl_company
     WHERE company_name = 'Small Bank Corporation'
     )
     EXCEPT
    (SELECT city
     FROM empl_company k
     WHERE k.company_name = s.company_name
     ) 
);

我成了一个错误 ORA-00907:缺少右括号 能告诉我这是什么问题吗?

2 个答案:

答案 0 :(得分:4)

EXCEPT运算符在Oracle中称为MINUS;

select company_name
from empl_company s
where not exists (
  select city
  from empl_company
  where company_name = 'Small Bank Corporation'
  MINUS
  select city
  from empl_company k
  where k.company_name = s.company_name
);

答案 1 :(得分:0)

从emp1_company中选择company_name不存在(从emp1_company中选择city_name ='Small Bank Corporation'和city in(选择city FROM empl_company k WHERE k.company_name = s.company_name));