求输出学生名字和它的课程
三张表:
s表 c表 sc表
id name id name sid cid
1 张三 2 语文 1 2select s.name, c.name from s, c, sc where s.id = sc.sid and c.id = cid;有人可以帮我看看这样写对吗?

解决方案 »

  1.   

    求输出学生名字和它的课程
    三张表:
    s表 c表 sc表
    id name id name sid cid
    1 张三 2 语文 1 2select s.name, c.name from s, c, sc where s.id = sc.sid and c.id = cid;
      

  2.   

    select s.name, c.name from s, c, sc where s.id = sc.sid and c.id = SC.cid
      

  3.   

    求输出学生名字和它的课程三张表:
    s表
    id name
    1 张三
    c表
    id name
    2 语文
    sc表
    sid cid
    1 2select s.name, c.name from s, c, sc where s.id = sc.sid and c.id = cid;
      

  4.   

    create table #s (id int, name varchar(20))
    insert into #s select 1, '张三'
    create table #c (id int, name varchar(20))
    insert into #c select 2, '语文'
    create table #sc (sid int, cid int)
    insert into #sc select 1,2select s.name, c.name from #s s,#c c,#sc sc where s.id=sc.sid and c.id=sc.cidselect s.name, c.name from #sc sc join #s s on sc.sid=s.id join #c c on sc.cid=c.id 两种都可以的
      

  5.   


    create table #s (id int, name varchar(20))
    insert into #s select 1, '张三'
    create table #c (id int, name varchar(20))
    insert into #c select 2, '语文'
    create table #sc (sid int, cid int)
    insert into #sc select 1,2select s.name, c.name from #s s,#c c,#sc sc where s.id=sc.sid and c.id=sc.cidselect s.name, c.name from #sc sc join #s s on sc.sid=s.id join #c c on sc.cid=c.id 
    态感谢了!
      

  6.   

    SELECT NAME,CLASS FROM S INNER JOIN C ON S.ID=C.ID
      

  7.   

    insert into #s select 1, '张三'mysql 下咋插不进数据呢?
      

  8.   

    提醒你一下:这几天老是有人拿mysql来忽悠学SQL server的家伙.
      

  9.   


    不好意思,开始没找着有MYSQL版的,
    刚看到了。嘿~
      

  10.   

    select s.name, c.name from #sc sc join #s s on sc.sid=s.id join #c c on sc.cid=c.id