Home > Database > Mysql Tutorial > 数据库多表操作

数据库多表操作

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:58:51
Original
1429 people have browsed it

数据库多表操作 学生表 student (sid,stuname,age) 课程表course (cid,cname,credit) 学生课程成绩表 stucourse (sid,cid,achi) 求 平均分大于85的学生平均成绩以及学生姓名 select student.stunme,avg(stucourse.achi) from student,stucourse where st

数据库多表操作

 

学生表 student (sid,stuname,age)

课程表course (cid,cname,credit)

学生课程成绩表 stucourse (sid,cid,achi)

 

求 平均分大于85的学生平均成绩以及学生姓名

 

select student.stunme,avg(stucourse.achi) from student,stucourse where student.sid=stucouse.sid group by

student.stuname baving avg(stucourse.achi) >85

 

创建学生表

create table student(

   sid varchar(32),

   stuname varchar(32),

   age int

 

添加一个唯一索引

create unique index student_sid_index on student(sid)

在学生表中添加身份证列 idcard 长度18 非空

alter table student add icard varchar(18) not null

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template