[英]Searching using more than 1 keywords, on more than 1 fields using PHP & MySQL
I would like to have a search engine using PHP and MySQL to perform searches like this: 我想要一个使用PHP和MySQL的搜索引擎来执行如下搜索:
I will search for bumblebee camaro , in about 3 fields in tables. 我将在表格的大约3个字段中搜索大黄蜂camaro 。
I want to have results that return rows with both texts (having bumblebee and camaro ) and also return the same result if I search for bumblebee cam . 我想要的结果是返回包含两个文本的行(具有大黄蜂和camaro ),并且如果我搜索大黄蜂cam也返回相同的结果。
I was using MATCH AGAINST IN BOOLEAN MODE
, but the result was record with bumblebee , record with bumblebee and camaro . 我当时
MATCH AGAINST IN BOOLEAN MODE
下使用MATCH AGAINST IN BOOLEAN MODE
,但是结果是用大黄蜂记录的,用大黄蜂和camaro记录的。
I don't want records with only bumblebee text, only the second one. 我不想只包含大黄蜂文本的记录,而只包含第二个。 How to do that?
怎么做?
My SQL was: MATCH (field1,field2,field3) AGAINST('+bumblebee cam' IN BOOLEAN MODE)
我的SQL是:
MATCH (field1,field2,field3) AGAINST('+bumblebee cam' IN BOOLEAN MODE)
Thanks for the response in advance! 感谢您的提前回复!
Btw, I did try to split the keyword, but it was not returning the correct answer, because somehow the word bumblebee from the field1, and camaro from the field2, if i split it. 顺便说一句,我确实尝试过拆分关键字,但是它没有返回正确的答案,因为如果我将其拆分,则不知何故,来自field1的bumblebee和来自field2的camaro。 it will show record the one that i dont need
它会显示记录我不需要的那个
MATCH (field1,field2,field3) AGAINST ('bumblebee cam' IN BOOLEAN MODE)
would search for one of the words 会搜索其中一个词
MATCH (field1,field2,field3) AGAINST ('+bumblebee +cam' IN BOOLEAN MODE)
would search both words 会搜索两个词
MATCH (field1,field2,field3) AGAINST ('-bumblebee +cam' IN BOOLEAN MODE)
would search Term without Search 会搜索不搜索的字词
just split the words and build it with using + - | 只需拆分单词并使用+-|构建它 , whatever needed.
,无论需要什么。
check documentation on : http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html 查看以下文档: http : //dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.