mysql中的错误1248

时间:2013-10-04 16:41:42

标签: mysql mysql-error-1248

我正在尝试运行此查询。

select *
from (select *
      from student
      where dept_name= ’Comp. Sci’)
      natural left outer join
     (select *
      from takes
      where semester = ’Spring’ and year = 2009);

但每次我得到

error# 1248: every derived table must have its own alias.

我尝试创建所有派生的表的别名,但每次都会出现相同的错误。

我该如何解决这个问题。我查了一些已回答的问题,但没有运气。

2 个答案:

答案 0 :(得分:0)

试试这个:::

select * from 
(select * from student s where dept_name= ’Comp. Sci’) as tempLeft 
left join (select * from takes t where semester = ’Spring’ and year = 2009) on (// join condition)

答案 1 :(得分:0)

为子查询添加别名:

select * 
from 
    (select * from student s where dept_name= 'Comp. Sci') as data1 
    natural left outer join (select * from takes t where semester = 'Spring' and year = 2009) as data2;