版权声明:本文为BUG先生原创文章,可任意转载,愿请附上本文链接,谢谢。 https://blog.csdn.net/Edogawa_Konan/article/details/81505756
- //建立学生表
- mysql> create table student(
- -> sno char(5) not null primary key,
- -> sname char(8) not null,
- -> ssex char(1) check(ssex='1' or ssex='0'),
- -> sage tinyint(2),
- -> sdept varchar(20))charset=utf8;
- //建立课程表
- mysql> create table course(
- -> courseid int not null auto_increment primary key,
- -> cname varchar(16) not null)charset=utf8;
- //建立成绩表
- mysql> create table sc (
- -> grade int not null,
- -> sno char(5) not null,
- -> courseid int not null)charset=utf8;
mysql> select student.sname,student.sno,course.cname,sc.grade from student,cours
e,sc where student.sno=sc.sno and course.courseid=sc.courseid;
mysql> select student.sname,student.sno,course.cname,sc.grade from student,cours
e,sc where student.sno=sc.sno and course.courseid=sc.courseid and student.sno='00001';