首页 新闻 会员 周边 捐助

求sql语句?(急)

0
悬赏园豆:20 [已解决问题] 解决于 2010-10-17 22:00

比较表a中ProductsName,Trademark,ProductsModel,CompanyName这些记录是否在表b中的ProductsName,Trademark,ProductsModel,CompanyName是否存在。如果存在更新表a中的字段Status为1否则为0,现在表a中没有CompanyName字段,他通过customerId和c中customerId关联,如何关联c中存在CompanyName。谢谢各位?

下面是:

update Base_Gx_ProductsInfo  set Status= 1, ProcessStatus=1
 from Base_Gx_ProductsInfo as A 
      inner join Base_State_ProductsInfo as B 
       on B.ProductsName=A.ProductsName
        and B.ProductsModel=A.ProductsModel and B.Trademark=A.Trademark

孤星赏月的主页 孤星赏月 | 初学一级 | 园豆:125
提问于:2010-10-17 15:33
< >
分享
最佳答案
0

试试这两个语句:


update Base_Gx_ProductsInfo set Status= 1, ProcessStatus=1
from Base_Gx_ProductsInfo as A
inner join (select ProductsName,Trademark,ProductsModel,customerID,
c.CompanyName
as CompanyName from Base_State_ProductsInfo t
inner
join C on c.customerId=t.customerId ) as B
on B.ProductsName=A.ProductsName
and B.ProductsModel=A.ProductsModel and B.Trademark=A.Trademark
and A.CompanyName=B.CompanyName

 


update Base_Gx_ProductsInfo set Status= 1, ProcessStatus=1
from Base_Gx_ProductsInfo as A
inner join Base_State_ProductsInfo as B
on B.ProductsName=A.ProductsName
and B.ProductsModel=A.ProductsModel and B.Trademark=A.Trademark
inner join C on c.customerId=B.customerId and A.CompanyName=c.CompanyName
收获园豆:20
邀月 | 高人七级 |园豆:25475 | 2010-10-17 18:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册