If I my term is for example iphone ipod the following query
SELECT id FROM products WHERE MATCH (name) AGAINST ('$term')
will give me results that contai开发者_如何转开发n both terms or only one of them.
How can I restrict to show me only results that contain both terms? Speed is my concern.
Thank you.
Add a + before every word:
$words = explode(" ", $term);
$all = implode(" +",$words);
$sql = 
   "SELECT id 
    FROM products
    WHERE MATCH (name) AGAINST ('+" . $all . "' IN BOOLEAN MODE)"
Documentation
Be sure to escape the input terms to prevent SQL Injection.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论