请教SQL语句

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

现在有两个数据库   a   和   b     里面都有一个表为sfcte     其中都有三个关键字段   te001   te002   te003  
   
  同时还有两个字段为te004   te005  
   
  我现在想做到   b中的sfcte   表进行更新,   把a中sfcte的te004   te005   付给b中的sfcte   条件是te001   te002   te003相同的   请问怎么解决     谢谢

· 网友精彩回答:

发表者:paoluo

update   b   set   te004=a.te004,te005=a.te005   from   a.dbo.sfcte   a   inner   join   b.dbo.sfcte   b   on   a.te001=b.te001   and   a.te002=b.te002   and   a.te003=b.te003    
   
  or  
   
  update   b   set   te004=a.te004,te005=a.te005   from   a.dbo.sfcte   a   ,b.dbo.sfcte   b   where     a.te001=b.te001   and   a.te002=b.te002   and   a.te003=b.te003    
   
 

发表者:libin_ftsafe

如果两个库在同一台服务器上:  
   
  update    
          b  
  set  
          te004   =   a.te004,  
          te005   =   a.te005  
  from  
          b..sfcte   b,    
          a..sfcte   a  
  where  
          b.te001   =   a.te001  
          and  
          b.te002   =   a.te002  
          and  
          b.te003   =   a.te003

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved