gremio10 14 Denunciar post Postado Novembro 9, 2010 Galera, assim, na minha tabela attribute, ela tem : id identification attribute_type name is_visible unit 13 product_peso_bruto product Peso Bruto 0 Kg 16 product_comprimento product Comprimento 0 cm 17 product_largura product Largura 0 cm 18 product_altura product Altura 0 cm E preciso chamar esses atributos para cada produto cadastrado. já fiz esse SQL que me pega tudo que preciso , menos os atributos: SELECT p.name AS nome_produto, sp.value AS de, sp.promotional_value AS por, sp.delivery_time AS prazo, rf.reference AS referencia, p.has_stock AS estoque, p.is_active AS ativo, ra.value AS valor FROM product p INNER JOIN shop_product sp ON (p.id = sp.product_id) INNER JOIN reference rf ON (p.id = rf.product_id) INNER JOIN reference_attribute ra ON (rf.id = ra.reference_id) INNER JOIN attribute at ON (at.id = ra.attribute_id) WHERE at.identification = 'product_peso_bruto' OR at.identification = 'product_largura' OR at.identification = 'product_comprimento' OR at.identification = 'product_altura' Tentei usando OR mas ele pega apenas um... Agradeço a ajuda. Compartilhar este post Link para o post Compartilhar em outros sites
Motta 645 Denunciar post Postado Novembro 9, 2010 IN ? ... at.identification in ('product_peso_bruto','product_largura','product_comprimento','product_altura') ... Compartilhar este post Link para o post Compartilhar em outros sites
gremio10 14 Denunciar post Postado Novembro 9, 2010 Motta, colocaria esse codigo em que local da query ?? Obrigado Compartilhar este post Link para o post Compartilhar em outros sites
Motta 645 Denunciar post Postado Novembro 9, 2010 ... WHERE at.identification in ('product_peso_bruto','product_largura','product_comprimento','product_altura') ... Compartilhar este post Link para o post Compartilhar em outros sites
gremio10 14 Denunciar post Postado Novembro 9, 2010 e para que eu pegue os valores individuais seria WHERE at.identification in ('product_peso_bruto','product_largura','product_comprimento','product_altura') AS peso,AS largura ... ? Compartilhar este post Link para o post Compartilhar em outros sites
Motta 645 Denunciar post Postado Novembro 9, 2010 SELECT p.name AS nome_produto, sp.value AS de, sp.promotional_value AS por, sp.delivery_time AS prazo, rf.reference AS referencia, p.has_stock AS estoque, p.is_active AS ativo, ra.value AS valor FROM product p INNER JOIN shop_product sp ON (p.id = sp.product_id) INNER JOIN reference rf ON (p.id = rf.product_id) INNER JOIN reference_attribute ra ON (rf.id = ra.reference_id) INNER JOIN attribute at ON (at.id = ra.attribute_id) WHERE at.identification in ('product_peso_bruto','product_largura','product_comprimento','product_altura') Caso ainda não funcione faça : SELECT distinct at.identification FROM product p INNER JOIN shop_product sp ON (p.id = sp.product_id) INNER JOIN reference rf ON (p.id = rf.product_id) INNER JOIN reference_attribute ra ON (rf.id = ra.reference_id) INNER JOIN attribute at ON (at.id = ra.attribute_id) E veja quais valores retormam para esta coluna na sua query. Compartilhar este post Link para o post Compartilhar em outros sites