0

I have tables similar to these here. ( these are rough examples).

// List of products
product
    id: int,
    hash: varchar(255),
    created: datetime,
    modified: timestamp

// List of available product attributes
product_attributes
    id: int
    attribName: varchar(255),
    created: datetime,
    modified: timestamp

// Map of attributes available for a product
product_attribute_map:
    id: int,
    productId: int (FK product.id),
    productAttributeId: int (FK product_attributes.id),
    created: datetime,
    modified: timestamp

// Values assigned to the attributes.
product_attribute_values
    id: int
    productId: int (FK product.id),
    productAttributeId: int (FK product_attributes.id),
    productAttributeValue: varchar(255)
    created: datetime,
    modified: timestamp

I want to be able to select all the products and their attributes and values. I would like the product_attributes.attribName to be the name of the column, and the product_attributes_values.productAttributeValue to fall into place under them in the query. I need this to be done dynamically I am not sure how to do it though.

Thoughts? Can this be done dynamically? or am I daydreaming?

thenetimp
  • 9,487
  • 5
  • 29
  • 42
  • unfortunately not all attributes will be available to all products and there fore would require multiple pivot tables. I am looking for a way to do this WITHOUT a pivot table..... – thenetimp Apr 22 '15 at 23:46
  • I am also not looking to hard code any of the attributes. So you're marking this as a duplicate is totally wrong. – thenetimp Apr 22 '15 at 23:48
  • application level would be the best place to do it – pala_ Apr 22 '15 at 23:49
  • i was hoping avoid doing it on the application level. There has to be a way to do this. – thenetimp Apr 22 '15 at 23:54

0 Answers0