PL / SQL - 连接3个表会错误地定义错误列

时间:2012-10-11 08:34:28

标签: sql plsql

我正在加入PL / SQL中的3个表,员工,部门以及管理人员的其他员工。但是当我运行脚本时,我得到了这个错误

Error report:
ORA-06550: line 19, column 9:
PL/SQL: ORA-00918: column ambiguously defined
ORA-06550: line 9, column 3:
PL/SQL: SQL Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

我是PL / SQL的新手,所以无法理解这些错误意味着什么。

这是开始块内的select语句,我得到错误

   select e.first_name||' '||e.last_name AS Employee ,
          m.first_name||' '||m.last_name AS Manager ,
          e.job_id AS jobemp , 
          d.department_name AS Department ,
          e.salary AS Salary
  into ename, manager, jobid, depn, sal
  from employees e join departments d 
          on (e.department_id = d.department_id)
        join employees m
          on (e.manager_id = m.employee_id)
  where salary = (select min(salary) from employees)
  ;

任何可以帮我识别此错误的人? 提前谢谢。

1 个答案:

答案 0 :(得分:4)

在where子句

中指定来自哪个表salary
    select e.first_name||' '||e.last_name AS Employee , 
          m.first_name||' '||m.last_name AS Manager , 
          e.job_id AS jobemp ,  
          d.department_name AS Department , 
          e.salary AS Salary 
  into ename, manager, jobid, depn, sal 
  from employees e join departments d  
          on (e.department_id = d.department_id) 
        join employees m 
          on (e.manager_id = m.employee_id) 
  where e.salary = (select min(salary) from employees);