LIKE %% multiples in PHP and MYSQL

0

I have the following code:

$sql="SELECT * FROM 'jsonBuscador' 
WHERE 'tags' LIKE '%$bafle%' AND ('tags' LIKE '%$marca1%' 
OR 'tags' LIKE '%$marca2%') AND 'tags' LIKE '%$size%' 
AND 'tags' LIKE '%$sistema%'";

in which I try to select the results based on search criteria such as: baffle / brand / size / system, I managed to get it to show me the results but with a brand, but when I try to show the results with several brands I returns elements that I have not requested, in particular I think what I'm trying to say is how to make a selectable filter Ebay style, but that is multiple, in which you can select more than one filter, I appreciate the help, greetings.

    
asked by user3033258 20.07.2018 в 01:49
source

1 answer

0

You have to change your logical operator. Instead of AND you have to use OR

$sql="SELECT * FROM 'jsonBuscador' 
WHERE 'tags' LIKE '%$bafle%' OR 'tags' LIKE '%$marca1%' OR 'tags' LIKE 
'%$marca2%' OR 'tags' LIKE '%$size%' OR 'tags' LIKE '%$sistema%'";
    
answered by 20.07.2018 в 01:53