简体   繁体   English

需要修改mySQL MATCH AGAINST查询的帮助

[英]Need help on modification to mySQL MATCH AGAINST query

I have a simple jQuery/PHP autocomplete text box that gets the matches from mySQL. 我有一个简单的jQuery / PHP自动完成文本框,可从mySQL获取匹配项。 In my case if a name in the DB is 就我而言,如果数据库中的名称

Brand new iPhone and iPod case

and the $q is $ q是

iph

the textbox will not pop out the above product name for me to select it until I write the entire matching word. 在我写下完整的匹配词之前,文本框不会弹出上面的产品名称供我选择。

With wildcards I get my expected result, but when $q is 使用通配符可以得到预期的结果,但是当$ q为

iphone ipod

I will not get the above product name. 我不会得到上面的产品名称。

$q = $_GET["q"];
WHERE name LIKE '%$q%'

What I have now is this below and my question is if there is a way to have the result before write the full word AND also to support the iphone ipod issue. 我现在的问题在下面,我的问题是在写完整单词之前是否有办法得到结果,并且还可以支持iphone ipod问题。

$q = $_GET["q"];
$words = explode(" ", $q);
$all = mysql_real_escape_string(implode(" +",$words));
WHERE MATCH (name) AGAINST ('+" . $all . "' IN BOOLEAN MODE)
$all = mysql_real_escape_string(implode("* +",$words));


WHERE MATCH (name) AGAINST ('+" . $all . "*' IN BOOLEAN MODE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM