Home >Database >Mysql Tutorial >mysql根据查询结果创建表_MySQL

mysql根据查询结果创建表_MySQL

WBOY
WBOYOriginal
2016-06-01 13:01:421202browse

现在假设存在三张表

s(sno,sname.sex,age,dept) //sno代表学生的学号 , sname代表学生姓名 , sex代表性别 ,age代表年龄,dept代表系

c(cno,cname,tname) //cno课程号 ,cname课程名 , tname老师名字

sc(sno,cno,grade) //sno学号,cno课程号,grade成绩

现有如下要求:将一门课的成绩大于等于80分学生的学号、姓名和系名新建一个基本表stu(sno,sname,dept)

create table stu (
select sno , sname ,dept from s where s.sno in (select sno from sc where sc.grade >= 80)
);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn