----create #table for table b
  select distinct id ,'' as subject,'' as title into #tableb from b 
----  得到每个Id只有一条记录
  update #tableb set #tableb.subject=b.subject,
                     #tableb.title=b.title
  from b
  where #tableb.id=b.id  select * from #tableb
---- 关联a,b
  select a.id,Name,age,subject,title from a,#tableb
  where a.id=#tableb.id  drop table #tableb