-2

how can i make a search in mysql by multiple words. Let's say i have a title "black handbag for womans". my search string is "handbag womans". I want to display all the products that have handbag and womans in title. I did an sql,it search the products that have handbag and womans but also products that only have handbag or womans, i want just those that have both words.

 $stmt = $dbh->prepare("SELECT * FROM Produse  
                        INNER JOIN Categorii on Produse.ID_Categorie=Categorii.ID_Categorie 
                       where MATCH Produse.Prod_Name  AGAINST ('$q' IN BOOLEAN MODE) order by Produse.Prod_Name  ASC");
        $stmt->execute();
chris227
  • 579
  • 9
  • 28

1 Answers1

0

Try this way This is for mysql query

SELECT     *
FROM       produse
INNER JOIN categorii
ON         produse.id_categorie=categorii.id_categorie
WHERE      produse.prod_name LIKE '%$q%'
ORDER BY   produse.prod_name ASC
krunal nerikar
  • 436
  • 4
  • 12