
-- ----------------------------------------------------------------------------------------
-- UPDATE picture titles including variant names
-- ----------------------------------------------------------------------------------------
SELECT
	ael.ArticleEntry_Language_Title, svil.ShopVariantItem_Language_Name, pl.Picture_ID, pl.Picture_Language_Title,
	CONCAT(TRIM(ael.ArticleEntry_Language_Title), ' - ', TRIM(svil.ShopVariantItem_Language_Name)) AS new_picture_title
FROM

-- UPDATE
Picture_Language AS pl, ArticleEntry_Picture AS aep,
ArticleEntry_Language AS ael, ShopArticleItem_Picture AS saip,
ShopArticleItem AS sai, ShopVariantItem_Language AS svil
-- SET pl.Picture_Language_Title = CONCAT(TRIM(ael.ArticleEntry_Language_Title), ' - ', TRIM(svil.ShopVariantItem_Language_Name))
WHERE
	pl.Picture_ID = aep.Picture_ID
	AND aep.ArticleEntry_ID = ael.ArticleEntry_ID
	AND pl.Language_Code = 'de' AND TRIM(IFNULL(pl.Picture_Language_Title,'')) = ''
	AND ael.Language_Code = 'de' AND TRIM(IFNULL(ael.ArticleEntry_Language_Title,'')) != ''
	AND pl.Picture_ID = saip.Picture_ID
	AND saip.ShopArticleItem_ID = sai.ShopArticleItem_ID
	AND sai.ShopVariantItem_ID = svil.ShopVariantItem_ID
	AND svil.ShopVariantItem_ID != 1 -- ignore "einzelvarianten"
	AND svil.Language_Code = 'de' AND TRIM(IFNULL(svil.ShopVariantItem_Language_Name,'')) != ''



-- ----------------------------------------------------------------------------------------
-- UPDATE common picture titles 
-- ----------------------------------------------------------------------------------------

SELECT
	ael.ArticleEntry_Language_Title, pl.Picture_Language_Title,
	TRIM(ael.ArticleEntry_Language_Title) AS new_picture_title
FROM

-- UPDATE
Picture_Language AS pl,
ArticleEntry_Picture AS aep,
ArticleEntry_Language AS ael
-- SET pl.Picture_Language_Title = TRIM(ael.ArticleEntry_Language_Title)
WHERE
	pl.Picture_ID = aep.Picture_ID
	AND aep.ArticleEntry_ID = ael.ArticleEntry_ID
	AND pl.Language_Code = 'de' AND TRIM(IFNULL(pl.Picture_Language_Title,'')) = ''
	AND ael.Language_Code = 'de' AND TRIM(IFNULL(ael.ArticleEntry_Language_Title,'')) != ''


