创建一个学生表
create table student(s_id int primary key,s_n varchar(20));
创建一个课程表,在这里说明,每一个学生可以选择3门课程,总共有6门课程
create table course (c_id int primary key,c_n varchar(20));
创建第三个表 ,转换使用的吧。
create table studentcourse(
-> sc_id int primary key,
-> sc_sid int,
-> sc_cid_1 int,
-> sc_cid_2 int,
-> sc_cid_3 int,
-> foreign key(sc_sid) references student(s_id),
-> foreign key(sc_cid_1) references course(c_id),
-> foreign key(sc_cid_2) references course(c_id),
-> foreign key(sc_cid_3) references course(c_id)
-> );
然后 开始 插入数据
insert into student () values(17060072,'zhang');
insert into student () values(17060071,'huang');
insert into course () values (1,'JAVA');
insert into course () values (2,'SQL');
insert into course () values (3,'JSP');
insert into course () values (4,'PYTHON');
insert into course () values (5,'HTML');
最后 就可以 查询 了。