左连接怎么对左边的表选择列

问题遇到的现象和发生背景

第六题不会写,我知道分开怎么写,但合起来我就不回了

用代码块功能插入代码,请勿粘贴截图
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表只选择课程名

我想要达到的结果

img

img

img

给表取别名,比如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);