MySQL FULL TEXT SEARCH仅筛选匹配的单词包含结果

时间:2022-06-12 06:11:17

I'm writing a full text query that kind for a search functionally. It need to get results if that only contain matched word, Ex-

我正在编写一个全文查询,以便在功能上进行搜索。如果仅包含匹配的单词,则需要获得结果

product names -

产品名称 -

1st product- inkjet epson printer 1158,

第一产品 - 喷墨爱普生打印机1158,

2nd product- inkjet hp printer 2250

第二产品 - 喷墨HP打印机2250

if the user search inject printer it should show both

如果用户搜索注入打印机,它应该显示两者

inkjet epson printer 1158,inkjet hp printer 2250

喷墨爱普生打印机1158,喷墨HP打印机2250

if the user search inkjet epson it should show one

如果用户搜索喷墨爱普生,它应该显示一个

inkjet epson printer 1158**

喷墨爱普生打印机1158 **

if the user search hp printer it should show one

如果用户搜索hp打印机,它应该显示一个

inkjet hp printer 2250

喷墨hp打印机2250

i used + operator for that

我用+运算符

ex

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+inkjet +epson ')
SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+hp +printer')

but i getting both products for the results, can anyone help me with this. thank you

但我得到了两个产品的结果,任何人都可以帮助我。谢谢

1 个解决方案

#1


0  

Try this

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+inkjet* +epson*' IN BOOLEAN MODE) OR

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ inkjet * + epson *'在BOOLEAN MODE中)或

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+inkjet +epson' IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ inkjet + epson'IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+hp* +printer*' IN BOOLEAN MODE) OR

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ hp * + printer *'IN BOOLEAN MODE)或

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+hp +printer' IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ hp + printer'IN BOOLEAN MODE)

#1


0  

Try this

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+inkjet* +epson*' IN BOOLEAN MODE) OR

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ inkjet * + epson *'在BOOLEAN MODE中)或

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+inkjet +epson' IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ inkjet + epson'IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+hp* +printer*' IN BOOLEAN MODE) OR

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ hp * + printer *'IN BOOLEAN MODE)或

SELECT * FROM products WHERE MATCH(pro_name) AGAINST('+hp +printer' IN BOOLEAN MODE)

SELECT * FROM products WHERE MATCH(pro_name)AGAINST('+ hp + printer'IN BOOLEAN MODE)