当我在做条件时,我在表格中插入数据时显示错误,即"无法找到多部分标识符"在sqlserver中
这是我的查询
SELECT CASE
WHEN p.id = tmp.ProductId and p.Deleted = 0 and p.Published = 1 and p.VisibleIndividually = 1
THEN
Insert into mysql_abc_Product(ProductId, abcStatus, IsDeleted, InTime, StoreId,LanguageId)
select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id
where isp.Id is NULL and p.Deleted = 'False' or p.Published = 'True' or VisibleIndividually = 'True'
ELSE
Insert into mysql_abc_Product(ProductId, abcStatus, IsDeleted, InTime, StoreId,LanguageId)
select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id
where isp.Id is NULL and p.Deleted = 'True' or p.Published = 'False' or VisibleIndividually = 'False'
END as Saleable, *
FROM Language l, Store s, Product p left outer join #temp tmp on tmp.productid = p.Id where isp.Id is NULL
答案 0 :(得分:1)
您应该将正确的联接放入此中,但这是您对上述查询的解决方案。你没有包括表格" Incremental_Solr_Product"符合" isp"进入你的最后一行来自陈述。
SELECT CASE
WHEN p.id = tmp.ProductId and p.Deleted = 0 and p.Published = 1 and p.VisibleIndividually = 1
THEN
Insert into Incremental_Solr_Product(ProductId, SolrStatus, IsDeleted, InTime, StoreId,LanguageId)
select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id
where isp.Id is NULL and p.Deleted = 'False' or p.Published = 'True' or VisibleIndividually = 'True'
ELSE
Insert into Incremental_Solr_Product(ProductId, SolrStatus, IsDeleted, InTime, StoreId,LanguageId)
select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id
where isp.Id is NULL and p.Deleted = 'True' or p.Published = 'False' or VisibleIndividually = 'False'
END as Saleable, *
FROM Language l, Store s, Product p left outer join #temp tmp on tmp.productid = p.Id
left join Incremental_Solr_Product isp on isp.ProductId = p.Id
where isp.Id is NULL