简单sql语句,student(学生表) course(课程表) choice(选课表)

2024-12-12 09:51:13
推荐回答(5个)
回答1:

学生表一张 s
课程表一张 c

select s.name from s
join c
on s.sid=c.sid
where c.name in ('数学',英语',语文','化学')

回答2:

select stuId,stuName from student where stuId in
(
select stuId from choice where courseId in (
select courseId from course where courseName='数学' or courseName='英语' or courseName='语文' or
courseName='化学'
)
)

回答3:

你不给表结构怎么帮你啊?

select stuName from student s inner join choice c on s.stuId=c.stuId
inner join course co on c.courseId=co.courseId
where courseName in ('数学','英语','语文','化学')

回答4:

select * from
student A inner Join Course B
...
where ..
大概这样

回答5:

select stu_name from student where stu_id in(select stu_id from choice where 课程的编号 in(select 课程编号 from course where 课程名称 in(化学,英语,语文,数学))group by stu_id having
count(distinct 课程编号)=4)

你这道题目应该是三张表都需要,选课表只有课程的编号,但是没有课程的名字,所以还需要去课程表里调出来。我也没想到写这么长,哪位DBA有兴趣可以给优化一下。