Q:

How to write a sql query that returns matches from a two searchvalues

Im trying to create a search-function in wich a user can combine two values to search for a person in a contacts list. 
I want the database to return posts that have matches in both values. 
Right now i have tried to do this: 
input = searchValueA, searchValueB
SELECT * FROM ContactsList WHERE lastName LIKE '%searchValueA%' OR firstName LIKE '%searchValueA%' OR company LIKE '%searchValueA%' OR phoneNumber LIKE '%searchValueA%' AND lastName LIKE '%searchValueB%' OR firstName LIKE '%searchValueB%' OR company LIKE '%searchValueB%' OR phoneNumber LIKE '%searchValueB%'; 

But this returns posts that match either of the searchvalues and both. I only want to get posts where both search values matches. 
Can I redefine the query to make it do what I want? 
Best regard from a sql-beginner

A:

I think you want parentheses in that condition:
WHERE (lastName LIKE '%searchValueA%' OR
       firstName LIKE '%searchValueA%' OR 
       company LIKE '%searchValueA%' OR
       phoneNumber LIKE '%searchValueA%'
      ) AND
      (lastName LIKE '%searchValueB%' OR
       firstName LIKE '%searchValueB%' OR
       company LIKE '%searchValueB%' OR
       phoneNumber LIKE '%searchValueB%'
      );

