MySQL Forums
Forum List  »  Newbie

Re: Search within a search.
Posted by: Phillip Ward
Date: August 03, 2020 05:51AM

The AND operator binds more "tightly" that the OR operator.

This is effectively what you currently have:

WHERE 
(
    customers.first_name LIKE '%stock%' 
)
OR 
(     Customers.last_name LIKE '%stock%' 
  AND orders.`status = 22
)

You need to wrap brackets around the things you want to "stay" together:

WHERE 
     orders.status = 22
AND 
(    customers.first_name LIKE '%stock%' 
  OR customers.last_name LIKE '%stock%' 
)

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
July 31, 2020 03:40PM
July 31, 2020 04:35PM
August 01, 2020 10:54AM
Re: Search within a search.
August 03, 2020 05:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.