/*
创建名称为
v_student_teacher
的视图
*/
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, ----
生源所在地
s.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
/*
使用视图
*/
select
* from v_student_teacher