我一直在尝试使用以下连接来更新两个表中的单个列,
update skus sk inner join products ss on (sk.id = ss.sk_number) set sk.style_id = (select id from categories where style_number = ss.st_number)
我已经为必填字段应用了索引,但这里skus表sk.id
是字符串类型的主键。
产品表:sk_number和st_number字段,其中也应用了索引。
我不知道该查询有什么问题?请与我分享您的想法
答案 0 :(得分:0)
试试这个......
示例:强>
UPDATE A
SET ControllingSalesRep = RA.SalesRepCode
from DHE.dbo.tblAccounts A
INNER JOIN DHE_Import.dbo.tblSalesRepsAccountsLink RA
ON A.AccountCode = RA.AccountCode
您的查询:
update sk set sk.style_id = (select id from categories where style_number = ss.st_number) from skus sk inner join products ss on (sk.id = ss.sk_number)
答案 1 :(得分:0)
试试这个......
update sk set sk.style_id = ca.id from categories ca inner join products ss on ca.style_number = ss.st_number inner join skus sk on (sk.id = ss.sk_number)