Page 1 sur 1

afficher les tailles d'un produit

Posté : 17 juil. 2014, 12:55
par fariss49
Bonjour
j'ai besoin de votre aide.

j'ai 4 tables mysql : produits->references->references_attributs->attributs

Table produits:
id_produit | nom_produit
1 | chemise

Table references :
id_reference | nom_reference
1 | chemise.rouge.36
2 | chemise.rouge.38
3 | chemise.rouge.40
4 | chemise.noir.36
5 | chemise.noir.40

Table references_attributs
id_reference | id_attribut
1 | 1
1 | 3
2 | 1
2 | 4
3 | 1
3 | 5
4 | 2
4 | 3
5 | 2
5 | 5

Table attributs
id_attribut | valeur
1 | rouge
2 | noir
3 | 36
4 | 38
5 | 40

chaque reference a 2 attributs taille + couleur
je veux lister juste les tailles de la chemise rouge(avec id_attribut = 1) qui sont (36/38/40)

merci d'avance

Re: afficher les tailles d'un produit

Posté : 17 juil. 2014, 18:35
par Elie
FROM `references_attributs` WHERE `references_attributs`.`id_attribut` = 1 AND (`references_attributs`.`id_attribut` = 3 OR `references_attributs`.`id_attribut` = 4 OR `references_attributs`.`id_attribut` = 5)
Le probleme est que rien ne les relis à la table produit.
Il faudrait un 3eme champ dans la table reference avec produit_id