--自然连接
select distinct sname from 学生 s,选课 e,课程 c,选课 e1,课程 c1
where s.sid=e.sid
and e.cid=c.cid
and s.sid=e1.sid
and e1.cid=c1.cid
and c.credit=3 and c1.credit=4
--in连接
select distinct sname from 学生
where 学生.sid in(select 选课.sid from 选课
where 选课.cid in (select 课程.cid from 课程
where 课程.credit=3 )
and 学生.sid in(select 选课.sid from 选课
where 选课.cid in (select 课程.cid from 课程
where 课程.credit=4 )))
--join连接
select distinct sname from 学生 s
join 选课 e on s.sid=e.sid
join 课程 c on e.cid=c.cid
join 选课 e1 on s.sid=e1.sid
join 课程 c1 on e1.cid=c1.cid
and c.credit=3 and c1.credit=4
--exists 连接
select distinct sname from 学生
where exists(select * from 选课
where 学生.sid=选课.sid
and exists (select * from 课程
where 课程.cid=选课.cid and 课程.credit=3 )
and exists (select * from 选课
where 选课.sid=学生.sid
and exists (select * from 课程
where 课程.cid=选课.cid and 课程.credit=4 )))