《数据库》 错误 ~1248 - Every derived table must have its own alias~
解决问题:“显示Comp. Sci. 系所有学生以及他们在2009年春季选修课的所有课程端的列表”
(1)错误源头:
select * from (select * from student where dept_name='Comp. Sci.')
natural left outer join //左外连接
(select * from takes where semester='Spring' and year=2009);
错误原因:
1248 - Every derived table must have its own alias
//这句话的意思是说每个派生出来的表都必须有一个自己的别名
//一般在多表查询时,会出现此错误。
(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 //右外连接(与左外连接相对称)
natural full outer join // 全外连接
natural join //自然连接