create table students(
sid int not null primary key auto_increment, sname char(4) not null, ssex char(2) not null);create table course( cid int not null primary key auto_increment, cname varchar(64) not null,);create table student_course( sid int not null, cid int not null, constraint for_key_sid foreign key(sid) references students(sid), constraint for_key_cid foreign key(cid) references course(cid), primary key(sid,cid));查询选修了所有课程的学生的学号和姓名:
select sid,sname from students where not exists(
select sid from course where not exists( select * from student_course where sid = students.sid and cid = course.cid ));