Guten Tag,
ich möchte einen Selcet-Befehl mit “WITH RECURSIVE” einbinden. Über HeidiSQL funktioniert der folgenden SELECT-Befehl:
WITH RECURSIVE category_path (catID, title, root) AS
(
SELECT shop_categories.id as catID, shop_categories.name_deu, shop_categories.name_deu as root
FROM shop_categories
WHERE parent_id = 0
UNION ALL
SELECT c.id, c.name_deu, CONCAT(cp.root)
FROM category_path AS cp JOIN shop_categories AS c
ON cp.catID = c.parent_id
)
SELECT shop_articles.id, art_nr, name_deu, menge, merkmal1.merkmal_deu AS merkmal1, merkmal2.merkmal_deu AS merkmal2, wert1.wert_deu AS wert1, wert2.wert_deu AS wert2, root AS hauptgruppe
FROM shop_articles
INNER JOIN shop_articles_info
ON shop_articles.parent_id = shop_articles_info.id
LEFT JOIN shop_werte wert1
ON wert1=wert1.id
LEFT JOIN shop_werte wert2
ON wert2=wert2.id
LEFT JOIN shop_merkmale merkmal1
ON merkmal1=merkmal1.id
LEFT JOIN shop_merkmale merkmal2
ON merkmal2=merkmal2.id
LEFT JOIN (SELECT parent_id AS parentId, cat_id As catId, root
FROM shop_article_to_cats
LEFT JOIN category_path
ON category_path.catID = shop_article_to_cats.cat_id) AS artCat
ON artCat.parentId = shop_articles.id
Bei der Erstelleung der Datenquelle kommt folgenden Fehlermeldung:
Unknown column ‘cp.catID’ in ‘on clause’
Kann man da irgendwas machen oder sind diese Befehle nicht erlaubt?
Gruß Dennis