-- SQL script to get shopware 5 seo paths with article number to later build new seo path for shopware 6

SELECT b.productID AS product_id, a.name, atri.attr1, LOWER(b.path) AS path, s.name AS shop_name, s.host, b.subshopID AS subshop_id
FROM s_articles as a
LEFT JOIN s_articles_attributes as atri ON a.id = atri.articleID
LEFT JOIN (
    SELECT seo.path, seo.org_path, SUBSTRING_INDEX(seo.org_path,'=',-1) AS productID, seo.subshopID
    FROM `s_core_rewrite_urls` as seo
    ) AS b ON a.id = b.productID
LEFT JOIN s_core_shops AS s on s.id = b.subshopID;
