Question

I am trying to get a search criteria to become the following SQL:

WHERE (a = 1 AND b = 2) OR (c = 3)

Magento2 Documentation only has the example where AND and OR are reversed. Is this even possible? It doesn't seem like it is.

Was it helpful?

Solution

https://en.wikipedia.org/wiki/Distributive_property

Distribution of disjunction over conjunction

P or (Q and R) <-> (P or Q) and (P or R)

So, you can transform you criteria to

WHERE (a = 1 OR c = 3) AND (b = 2 OR c = 3)

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top