---
title: "match against"
author: "2014马年"
date: "2016-11-16T19:47:33Z"
tags: []
categories: ["数据库"]
slug: "match-against"
draft: false
lastmod: "2016-11-16T19:47:33Z"
id: 2338419
url: "https://20142014.iteye.com/blog/2338419"
---

match against

 

Full-Text 在5.6之前 只能用于 MyISAM ，5.6开始 可用于InnoDB

 

 

id name

1 张三

2 张四

3 张五

4 李三

5 李四

6 李五

1\. Boolead Full-text Searches

 

说明：

\+ AND

\- AND NOT

space or

 

\###

select * from table\_xxx\_user where match(name) against(‘+张 -四 -五’  IN BOOLEAN MODE)

 

结果：

1 张三

 

\###

select * from table\_xxx\_user where match(name) against(‘张 四 五’  IN BOOLEAN MODE)

1 张三

2 张四

3 张五

5 李四

6 李五

 

\###

select * from table\_xxx\_user where match(name) against(‘+张 四’  IN BOOLEAN MODE)

 

结果：

张四排第一个

 

2 张四

1 张三

3 张五

 

 

2\. default natural language full-text searches