怎么用sql写这句话

来源:百度知道 编辑:UC知道 时间:2024/09/23 15:30:58
怎么用sql写这句话:Display those course record(s) in Table Course with Mary Wong (using student_id ‘50121468’) enrolled?

course表中有学生的所有record
course_id表示相关课程的课程编号

如果student_id这个字段 在course表中
select * from course where student_id = '50121468'

如果如果student_id 这个字段不在course表中
则做一下标间链接
select * from course
where course.course_id = student.course_id and student_id = '50121468'
(因为course_id这个字段在course和student两个表中都有,
为了不产生歧义,
所以在用到时,前边要带表名,
而student_id只在student表中有,
所以在用到的时候不用带表名)

这个问题不清不楚啊,连个表结构都没有怎么回答啊

select * from course
where course.course_id = student.course_id and student_id = '50121468'