Mysql全文搜索与匹配和反对 [英] Mysql full text search with match and against

查看:45
本文介绍了Mysql全文搜索与匹配和反对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在描述字段上使用 mysql 全文搜索.

I have to use mysql full text search on description field.

现在假设我在一个表中有以下 4 条记录:

Now suppose i have following 4 records in a table :

 Description field:
    aa bb cc dd
    xx aa ff gg
    hh kk cc qq
    cc ee tt aa

现在,如果我搜索术语aa cc",那么它应该读取这两个词必须在记录中的描述.所以下面的记录应该是结果.

Now if i search term "aa cc", then it should read those description where these two words must be there in record. So following records should be result.

  aa bb cc dd
    cc ee tt aa

如何编写mysql match() against()查询?

How to write mysql match() against() query ?

推荐答案

假设你的表名是 table1 并且包含字符串的列是 col_name 那么你可以使用以下查询

Assume your table name is table1 and column which contain string is col_name then you can use following query

select * from table1 where col_name like '%aa%' and col_name like '%cc%'

这篇关于Mysql全文搜索与匹配和反对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆