比较表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
试试这两个语句:
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