I am not an SQL developer but my understanding is that WP_Query cannot do AND and OR queries which is what I need.
Here’s my requirements. The final outcome should be that if a user selects from the ProductType dropdown and clicks the search button, the page should return the results based on that term from the select menu. If they select an option from ProductGroup and hit the search button then the results need to return based on the selection.
If both dropdown menus have options selected, both ProductType and ProductGroup needs to be queried and the results returned. So it needs to be an AND or OR query that returns the results and not just one or the other.
This would be my pseudo code attempt.
If ProductType selected Return all ProductTypes If ProductGroup selected Return all ProductGroups If ProductType AND ProductGroup selected Return filtered ProductTypes and ProductGroups
I’d appreciate some help with this as SQL is no my “first” language 🙂 Thank you.
- The topic ‘AND and OR query in WordPress wpdb’ is closed to new replies.