Query liefert nicht das, was erwartet wird

Hallo, folgendes Query sollte eigentlich für den Wert attribute_names_count zumindest eine 1 ausgeben. Ich bekomme aber durchweg eine 0 ausgegeben und frage mich, warum? Folgendes Query liefert, wie zu erwarten, für attribute_names_count durchweg eine 1…

SELECT COUNT(property_group_option_translation.name) AS attribute_names_count,property_group_option_id FROM 
property_group_option_translation
GROUP BY property_group_option_translation.property_group_option_id;

Folgendes Query tut das aber nicht. Sind die LEFT JOINS falsch aufgebaut, oder ist das LEFT JOIN an sich das Problem, ich weiß es nicht. Weiß jemand Rat?

SELECT
    product.id,product.product_number,
    COUNT(property_group_option_translation.name) AS attribute_names_count,
    IF(COUNT(DISTINCT property_group_option_translation.name) > 1, 'TRUE', 'FALSE') AS has_multiple_attribute_names
FROM
    product
LEFT JOIN product_property ON
    product_property.product_id = product.id
LEFT JOIN  property_group_option ON 
    property_group_option.property_group_id = product_property.property_group_option_id
LEFT JOIN property_group_option_translation ON 
    property_group_option.id = property_group_option_translation.property_group_option_id
WHERE
    product.parent_id IS NOT NULL
GROUP BY
    product.id;

Das ist der Response:

Wäre tatsächlich gut gewesen, wenn du es mal in Worte gefasst hättest, was genau du erreichen willst. Ich vermute du willst die Anzahl an Eigenschaften pro Produkt anzeigen lassen?
Dann reicht es auch so:

SELECT
    p.id,
    p.product_number,
    COUNT(pp.property_group_option_id) AS attribute_names_count
FROM
    product p
LEFT JOIN product_property pp ON
    pp.product_id = p.id
    
    WHERE
    p.parent_id IS NOT NULL
GROUP BY
    p.id;

Jedoch bin ich mir bei deinem has_multiple_attribute_names unsicher… wenn deine Eigenschaften richtig gepflegt sind sollte da immer eine 1 kommen, wenn du den Wert „red“ in die jeweiligen Sprachen übersetzt hast.

Schreib mal was du vor hast…

Das wollte ich erreichen und habe ich erreicht:

SET @languageID='2fbb5fe2e29a4d70aa5854ce7ce3e20b';
SELECT product.id,product.product_number,
COUNT(DISTINCT property_group_translation.name) AS attribute_names_count,
IF(COUNT(DISTINCT property_group_translation.name) > 1, 'TRUE', 'FALSE') AS has_multiple_attribute_names,property_group_translation.name
FROM product
LEFT JOIN product_property
ON product_property.product_id = product.id
LEFT JOIN property_group_option
ON product_property.property_group_option_id=property_group_option.id
LEFT JOIN property_group_translation ON property_group_option.property_group_id=property_group_translation.property_group_id
WHERE
product.parent_id IS NOT NULL
AND property_group_translation.language_id=UNHEX(@languageID)
GROUP BY
product.product_number,property_group_translation.name
HAVING
attribute_names_count>=1;