Hi,
ich steh grad irgendwie voll auf dem Schlauch :-/
Beim dazujoinen von Produktattributen ... da muss es doch irgend ne Kurzschreibweise/Möglichkeit zum verkürzen geben oder? Dass sieht doch sonst irgendwie seltsam aus, wenn ich 20 und mehr Attribute joine?
Schonmal Danke fürs lösen vom Knoten in meinem Kopf ... der platzt sonst noch
Grüsse - Stef
ich steh grad irgendwie voll auf dem Schlauch :-/
Beim dazujoinen von Produktattributen ... da muss es doch irgend ne Kurzschreibweise/Möglichkeit zum verkürzen geben oder? Dass sieht doch sonst irgendwie seltsam aus, wenn ich 20 und mehr Attribute joine?
PHP-Code:
SELECT
p.id,
p.ext_id,
p.name,
ifnull(a1.value, 'n/a') AS color,
ifnull(a2.value, 'n/a') AS material,
ifnull(a3.value, '0') AS width,
ifnull(a4.value, '0') AS height,
ifnull(a5.value, '0') AS depth,
#...
FROM
products AS p
LEFT JOIN
attributes AS a1 ON p.id = a1.related_id AND a1.deleted = 0 AND a1.relation = 'products' AND a1.attribute = 'color'
LEFT JOIN
attributes AS a2 ON p.id = a2.related_id AND a2.deleted = 0 AND a2.relation = 'products' AND a2.attribute = 'material'
LEFT JOIN
attributes AS a3 ON p.id = a3.related_id AND a3.deleted = 0 AND a3.relation = 'products' AND a3.attribute = 'width'
LEFT JOIN
attributes AS a4 ON p.id = a4.related_id AND a4.deleted = 0 AND a4.relation = 'products' AND a4.attribute = 'height'
LEFT JOIN
attributes AS a5 ON p.id = a5.related_id AND a5.deleted = 0 AND a5.relation = 'products' AND a5.attribute = 'depth'
#...
Grüsse - Stef
Kommentar