Answer the question
In order to leave comments, you need to log in
Product filters WHERE AND or OR ?
Product filter. Products have an option type (for example, screen diagonal, processor frequency...), type has a value (15.6`, 17`, 3Gz, 2Gz...)
This is how I can select, for example, all Asus:
Product.where("
(option_types.id = 12 AND option_values.id IN (96,100))
")
Product.where("
(option_types.id = 58 AND option_values.id IN (337,338,340,341))
")
Product.where("
(option_types.id = 12 AND option_values.id IN (96,100))
AND (option_types.id = 58 AND option_values.id IN (337,338,340,341))
")
Product.where("
(option_types.id = 12 AND option_values.id IN (96,100))
OR (option_types.id = 58 AND option_values.id IN (337,338,340,341))
")
Answer the question
In order to leave comments, you need to log in
AND - an operator that displays records if the first and second conditions are true / true
OR - an operator that displays records if at least one of the two conditions is true / true
so your approach is wrong
so think about your approach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question