注册 登录
编程论坛 SQL Server论坛

求 SQL 2005 中第11章11-1正确代码?

smile871 发布于 2012-02-07 14:57, 427 次点击
各位大虾:
教材中原代码意为建立创建一个能同时反映学生与老师信息的视图,书中原代码如下:

use school
go
create view v_student_teacher
as
select s.id as 'student_id',
s.name      as 'student_name',
s.gender    as 'student_gender',
s.age       as 'student_age',
s.grade,
s.class,
s.teacher_id as 's_teacher_id',
s.parents_id,
s.graduation,
s.city,
c.cardno,
t.id       as 'teacher_id',
t.name     as 'teacher_name',
t.gender   as 'teacher_gender',
t.age      as 'teacher_age',
t.subject,
t.teaching_age,
t.position,
t.salary,
from student as s
inner join
teachers as t on s.teacher_id=t.id
go

执行时总是提示:

消息 156,级别 15,状态 1,过程 v_student_teacher,第 22 行
关键字 'from' 附近有语法错误。

求各位大虾们给指正,谢谢!
2 回复
#2
png2012-02-07 22:55
t.salary,

变成

t.salary
#3
smile8712012-02-08 08:42
OK, 谢谢楼上的Png!!!
1