mySQL innoDB - MATCH()... AGAINST无法提供预期的结果

时间:2016-08-21 07:16:13

标签: mysql pdo full-text-search

innoDB我使用以下语句搜索关键字。表格companynote已被Fulltext编入索引。虽然数据库中只有一行Abraham Lincoln LTD而我搜索Abraham但我没有得到任何结果。事实上,我没有从全文索引表中获得任何结果。我在这做错了什么? mySQL Server版本是:5.7.13

$query = $this->con->prepare('SELECT 
                                    clients.id, 
                                    clients.num, 
                                    clients.company, 
                                    countries.en as country, 
                                    clients.country_id , 
                                    clients.city, 
                                    clients.mail, 
                                    clients.note 
                                    FROM clients, countries 
                                    WHERE clients.country_id=countries.id 
                                    AND (   MATCH (clients.company) AGAINST (:keyword) 
                                        OR  MATCH (clients.note)    AGAINST (:keyword)
                                        OR (countries.en=:keyword) 
                                        OR (clients.client_num=:keyword) 
                                        OR (clients.city=:keyword) 
                                        OR (clients.email=:keyword)  ) ');

编辑:

在没有得到有用的答案后,我试着找到另一种方法。所以我现在使用这个代码:

 $query = $this->db_con->prepare('
                                (SELECT 
                                clients.ID, 
                                clients.num, 
                                clients.company, 
                                countries.en as country, 
                                clients.country_id , 
                                clients.city, 
                                clients.email_1, 
                                clients.note 
                                FROM clients, countries 
                                WHERE clients.country_id=countries.ID 
                                AND ( MATCH (clients.company) AGAINST (:keyword)
                                OR      MATCH (clients.note)    AGAINST (:keyword)  )  )
                                UNION
                                (SELECT 
                                clients.ID, 
                                clients.num, 
                                clients.company, 
                                countries.de as country, 
                                clients.country_id , 
                                clients.city, 
                                clients.email_1, 
                                clients.note 
                                FROM clients, countries 
                                WHERE clients.country_id=countries.ID 
                                AND ( (countries.en     =:keyword)
                                OR    (clients.city     =:keyword)  
                                OR    (clients.num      =:keyword)  
                                OR    (clients.email_1  =:keyword) )    )
                              ');

它起着推崇的作用。我可以在一个调用(语句)中搜索全文中的未使用表和其他表。

但对我而言,它看起来有点复杂,并且需要时间来消耗数据库,所以我的问题是,是否有更简单的方法来快速获得结果?
当前的DB有2.500个客户端,25个col。只要。在未来5年内,DB不会超过10,000个客户。

0 个答案:

没有答案