Comprobar la existencia de combinaciones de asociaciones a partir de una tabla

Folks, I am looking for the best way to retrieve following information. I got a table with products and options assigned to them. Then I got a list of option combinations and wanting to know the existence of products for my combinations.

product to option table

  1. p1 - option1
  2. p1 - option2
  3. p1 - option3
  4. p2 - option2
  5. p2 - option3
  6. p3 - option3
  7. p3 - option4

My option combinations are [option1,option2], [option1,option4], [option2,option4] and [option3,option4]

My expected result is [option1,option2] and [option3,option4]

-The selection is based on, there should be at least one product associated with all the options in a combination. Here [option1, option2] is associated to p1 and [option3,option4] associated to p3. If the combination is distributed among multiple products then that combination will not be selected. Also there could be n number of options in a combination.

Gracias de antemano!

preguntado el 05 de mayo de 13 a las 18:05

Please clarify your example. Why is "[option1,option2] and [option3,option4]" the right answer? -

Sorry. The selection is based on, there should be at least one product associated with all the options in a combination. Here [option1, option2] is associated to p1 and [option3,option4] associated to p3. If the combination is distributed among multiple products then that combination will not be selected. Also there could n number of items in a combination. -

select option from yourtable group by product gets you most of the way there. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.