join 问题

楼主zsyp(zsyp)2005-12-22 17:42:49 在 MS-SQL Server / 应用实例 提问

现在有两个不相干的表  
  表   a    
  node       name         sex  
  1001       aa             m  
  1002       bb             n  
  ...         ...           ...  
     
  表b  
  school       class  
  aa               1  
  aa               2    
  ...             ...    
   
  结果  
  1001     aa     1  
  1002     aa     2 问题点数:50、回复次数:5Top

1 楼libin_ftsafe(子陌红尘:当libin告别ftsafe)回复于 2005-12-22 17:46:58 得分 40

select   identity(int,1,1)   as   id,*   into   #t1   from   表a  
  select   identity(int,1,1)   as   id,*   into   #t2   from   表b  
  select   a.Code,b.School,b.Class   from   #t1   a,#t2   b   where   a.id=b.id   order   by   a.idTop

2 楼happyflystone(无枪的狙击手)回复于 2005-12-22 18:06:36 得分 0

同意一楼Top

3 楼lisiyong(小样)回复于 2005-12-22 18:11:33 得分 0

dingTop

4 楼zsyp(zsyp)回复于 2005-12-22 21:43:31 得分 0

用一条语句执行可不可以Top

5 楼wangtiecheng(不知不为过,不学就是错!)回复于 2005-12-22 21:47:22 得分 10

不行,只能借助临时表和其中的自动IDTop

你可能对以下的问题也比较感兴趣....