Като MySQL ръководството казва:
Нека разгледаме примерната таблица:
mysql> select * from articles;
+----+-----------------------+------------------------------------------+
| id | title | body |
+----+-----------------------+------------------------------------------+
| 1 | PostgreSQL Tutorial | DBMS stands for DataBase ... |
| 2 | How To Use MySQL Well | After you went through a ... |
| 3 | Optimizing MySQL | In this tutorial we will show ... |
| 4 | 1001 MySQL Tricks | 1. Never run mysqld as root. 2. ... |
| 5 | MySQL vs. YourSQL | In the following database comparison ... |
| 6 | MySQL Security | When configured properly, MySQL ... |
+----+-----------------------+------------------------------------------+
mysql> SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('"database comparison"' IN BOOLEAN MODE);
+----+-------------------+------------------------------------------+
| id | title | body |
+----+-------------------+------------------------------------------+
| 5 | MySQL vs. YourSQL | In the following database comparison ... |
+----+-------------------+------------------------------------------+
Редът има значение, когато думите са цитирани:
mysql> SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('"comparison database"' IN BOOLEAN MODE);
Empty set (0.01 sec)
Когато премахнем кавичките, той ще търси редове, съдържащи думи „база данни“ или „сравнение“:
mysql> SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('database comparison' IN BOOLEAN MODE);
+----+---------------------+------------------------------------------+
| id | title | body |
+----+---------------------+------------------------------------------+
| 1 | PostgreSQL Tutorial | DBMS stands for DataBase ... |
| 5 | MySQL vs. YourSQL | In the following database comparison ... |
+----+---------------------+------------------------------------------+
Редът няма значение сега:
mysql> SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('comparison database' IN BOOLEAN MODE);
+----+---------------------+------------------------------------------+
| id | title | body |
+----+---------------------+------------------------------------------+
| 1 | PostgreSQL Tutorial | DBMS stands for DataBase ... |
| 5 | MySQL vs. YourSQL | In the following database comparison ... |
+----+---------------------+------------------------------------------+
Ако искаме да получим редове, съдържащи или дума "PostgreSQL", или фраза "сравнение на база данни", трябва да използваме тази заявка:
mysql> SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('PostgreSQL "database comparison"' IN BOOLEAN MODE);
+----+---------------------+------------------------------------------+
| id | title | body |
+----+---------------------+------------------------------------------+
| 1 | PostgreSQL Tutorial | DBMS stands for DataBase ... |
| 5 | MySQL vs. YourSQL | In the following database comparison ... |
+----+---------------------+------------------------------------------+
Уверете се, че думите, които търсите, не са в списък със спирателни думи , които се игнорират.