第六题不会写,我知道分开怎么写,但合起来我就不回了
mysql> select Course.cname,*
-> from Course,SC
-> where Course.Cno=SC.cno;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*
from Course,SC
where Course.Cno=SC.cno' at line 1
想过用左连接,但是怎么对左边,即course表只选择课程名
给表取别名,比如select a.cname, b.* from Course a,SC b where a.Cno=b.cno,希望对您有所帮助,有用的话采纳一下哈
如果SC中的SNO有不在student中的记录,需要关联student,去除多余SNO:
select cname,course.* from course where cno in
(
select distinct cno from sc where sno in
(select sno from student)
);
如果SC中的SNO 仅包含student中的sno, 则只关联sc即可。
select cname,course.* from course where cno in
( select distinct cno from sc);