insert into A select ID=1,name,成绩=0 where not exist(A.科目=B.name)

解决方案 »

  1.   

    Select b.ID,b.科目,IsNULL(a.成绩,0) as  成绩
    from 表A as a right Join 表B as b
          on a.id=b.id
      

  2.   

    to  WangZWang(阿来) ( ) :不是通过ID来关连的!其实就是这个意思:通过科目名来关连的!
      

  3.   

    Select b.ID,b.科目,IsNULL(a.成绩,0) as  成绩
    from 表A as a right Join 表B as b
          on a.科目=b.Name
      

  4.   

    select c.ID,d.[科目],isnull(d.[成绩],0) as [成绩]
      from (select a.Id, b.name
              from table a ,table b ) c 
           left join tablea d 
             on c.id =d.id 
             and c.name=d.name