
CREATE TEMPORARY TABLE IF NOT EXISTS `TmpDel` (
	`ShopArticleItem_ID` INT,
	`ShopVariantAttribute_ID` INT
);

INSERT INTO `TmpDel` (ShopArticleItem_ID, ShopVariantAttribute_ID)
SELECT
	ShopArticleItem_ShopVariantAttribute.ShopArticleItem_ID,
	ShopArticleItem_ShopVariantAttribute.ShopVariantAttribute_ID
FROM ShopArticleItem
INNER JOIN ShopArticle USING (ShopArticle_ID) 
INNER JOIN ShopArticleItem_ShopVariantAttribute USING (ShopArticleItem_ID)
INNER JOIN ShopVariantAttribute USING (ShopVariantAttribute_ID)
WHERE
	ShopArticle.ShopVariant_Code != ShopVariantAttribute.ShopVariant_Code;
	
	
DELETE ShopArticleItem_ShopVariantAttribute
-- SELECT *
FROM ShopArticleItem_ShopVariantAttribute, TmpDel
WHERE
	ShopArticleItem_ShopVariantAttribute.ShopArticleItem_ID = TmpDel.ShopArticleItem_ID
	AND ShopArticleItem_ShopVariantAttribute.ShopVariantAttribute_ID = TmpDel.ShopVariantAttribute_ID;

