Search breaks with multiple where criteria

QuestionsSearch breaks with multiple where criteria
Matt Lind asked 5 years ago

When I define a query to pull the data to the grid from MySql if there is more than two column search strings it breaks the grid search and filters.

For example, I have my custom query as:

SELECT * FROM Customers WHERE Country=‘US’ AND State=‘CA’ OR Country=‘US’ AND State=‘WA’

Anything more than two clauses and all search and filter functionality stops working. Any suggestions?

Thanks.

1 Answers
Abu answered 5 years ago

You need to use ( ) across your where conditions otherwise OR condition will always get satisfied and return recordset. Where you need () depends on your precedence. e.g.

SELECT * FROM Customers WHERE (
(Country=‘US’ AND State=‘CA’) OR (Country=‘US’ AND State=‘WA’)
)

Your Answer

6 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?