haben 3 TabellenMysql Multi verbinden mit Zahl
product_tags
product_id | tag
___________________
50 | new
50 | blac
66 | new
50 | green
111 | new
111 | white
products_to_categories
product_id | category_id
____________________
50 | 69
50 | 68
111 | 40
111 | 70
Kategorien
category_id | parent_id (parent category id)
____________________
68 | 0
69 | 68
70 | 68
Notwendigkeit Alle Tags nach Beliebtheit (count Produkt) in der Kategorie sortiert 68 und seine alle Unterkategorien (alle Kategorien mit Eltern-ID 68)
mein Start Abfrage
SELECT tag
FROM product_tags opd
LEFT JOIN products_to_categories optc ON optc.product_id = opd.product_id
LEFT JOIN categories optx ON optx.parent_id = '68'
WHERE opd.tag <> ''
AND optx.parent_id = '68'
ORDER BY optc.product_id DESC
Ergebnis falsches Ergebnis gebe ich brauchen
tags
_____
new (2)
white (1)
Wird ein Fehler angezeigt? Deine Frage ist nicht ganz klar ... – Ilja
nein ich habe ein falsches Ergebnis. Meine Frage ist falsch und nicht geben, Tags aus gewählter Kategorie und Kind Unterkategorien –
@SMNat meine angepasst Antwort –