解决问题:“显示Comp. Sci. 系全部学生以及他们在2009年春季选修课的全部课程端的列表”ci
(1)错误源头:it
select * from (select * from student where dept_name='Comp. Sci.')
natural left outer join //左外链接
(select * from takes where semester='Spring' and year=2009);table
错误缘由:
1248 - Every derived table must have its own alias
//这句话的意思是说每一个派生出来的表都必须有一个本身的别名
//通常在多表查询时,会出现此错误。select
(2)改正:
select * from (select * from student where dept_name='Comp. Sci.') as a
natural left outer join
(select * from takes where semester='Spring' and year=2009) as b;查询
推展:natural right outer join //右外链接(与左外链接相对称)tab
natural full outer join // 全外链接join
natural join //天然链接错误