1

以下查询无法解析:

select t.ename, t.received, d.loc from  
(  
  select e.ename, eb.received , e.deptno  
  from emp e left outer join  emp_bonus eb  
  on  
  e.empno=eb.empno  
)  
as t  
join dept as d on d.deptno = t.deptno;  

出现错误:

字段列表中的列“deptno”不明确

但是这个查询被成功解析:

select t.ename, t.received, d.loc from  
(  
  select e.ename, eb.received , e.deptno  
  from emp e left outer join  emp_bonus eb  
  on  
  e.empno=eb.empno  
)  
as t, dept as d where d.deptno = t.deptno   

我只更改了JOIN ON为什么t, dept where
第一个版本会失败?

4

1 回答 1

1

第一个查询在 mysql 5.1 版中完美运行, 请参阅演示

于 2013-07-07T17:18:11.303 回答